ngrx-store

Close subscription on condition with takeUntil()

感情迁移 提交于 2019-12-04 05:51:07
问题 I have a subscription to get providers from a NgRx reducer. I want to use takeUntil() to automatically close the subscription when is finally returns an array that has content: // Fetch providers this.store.pipe(select(reducer.getProviders)) // .takeUntil(reducer.getProviders.length > 0) .subscribe(providers => { if (providers) { this.providers = providers; // takeUntil(/** something **/); } }); Can someone help me with this? I can't figure out how to make use of takeUntil() 回答1: takeUntil

Angular 2+/4/5/6/7: Smart, dumb and deeply nested component communication

匆匆过客 提交于 2019-12-03 03:10:33
问题 NOTE: for simplicity consider the component depths as: - Smart (grand)parent level 0 - dumb child level 1 .... - dumb grandchild level 2 ....) There are various options and conditions on how smart/grand/parent/child components communicate and pass data up and down a MULTI-LEVEL (at least 3 levels) chain. We'd like to keep our 'smart' (grand)parent component as the only component that has access to our data service (or atomic/immutable store) and it will drive exchange of information with

Angular 2+/4/5/6/7: Smart, dumb and deeply nested component communication

大城市里の小女人 提交于 2019-12-02 16:41:20
NOTE: for simplicity consider the component depths as: - Smart (grand)parent level 0 - dumb child level 1 .... - dumb grandchild level 2 ....) There are various options and conditions on how smart/grand/parent/child components communicate and pass data up and down a MULTI-LEVEL (at least 3 levels) chain. We'd like to keep our 'smart' (grand)parent component as the only component that has access to our data service (or atomic/immutable store) and it will drive exchange of information with 'dumb' (grand)children. The options we see are: Anti-pattern(?) : Pass data down and up the component chain

Observable with rx broken after error

南楼画角 提交于 2019-12-01 18:29:05
问题 Im trying to write login flow for my app using ngrx store + ng effects. I have managed to write it and it works in happy scenerio, but when user inputs wrong values to the form, so that server responds with 401, the next login attempt has no effects. I have read that the exception must be catch when working with observables in order not to 'break' the stream, but as far i know I'm catch the exception and still its now working. belowe the code; export class LoginComponent { logged = new

Observable with rx broken after error

微笑、不失礼 提交于 2019-12-01 18:13:05
Im trying to write login flow for my app using ngrx store + ng effects. I have managed to write it and it works in happy scenerio, but when user inputs wrong values to the form, so that server responds with 401, the next login attempt has no effects. I have read that the exception must be catch when working with observables in order not to 'break' the stream, but as far i know I'm catch the exception and still its now working. belowe the code; export class LoginComponent { logged = new Observable<any>(); constructor(private store: Store<AppStore>) { this.logged = store.select('login'); } login

Angular - Convert a Observable<number> to a number

孤人 提交于 2019-12-01 10:35:37
I'm using ngrx store to record state, my state currently holds my list of accounts and the current page (for paging). On my list of accounts component i call the store to get the current page and pass that to a service (web api) to get the list of accounts. this.currentPage$ = this.store.select(getCurrentPage); My angular service is expecting a variable (currentPage) but as a type of number, the store select returns an Observable. getListOfCustomer(currentPage: number): Observable<ListDto<CustomerList>> {} My variable this.currentPage$ is currently a type of Observable<number> How can i

Angular - Convert a Observable<number> to a number

本秂侑毒 提交于 2019-12-01 06:40:17
问题 I'm using ngrx store to record state, my state currently holds my list of accounts and the current page (for paging). On my list of accounts component i call the store to get the current page and pass that to a service (web api) to get the list of accounts. this.currentPage$ = this.store.select(getCurrentPage); My angular service is expecting a variable (currentPage) but as a type of number, the store select returns an Observable. getListOfCustomer(currentPage: number): Observable<ListDto

Ngrx Store Resets after browser refresh. How to make the application preserve the state?

六眼飞鱼酱① 提交于 2019-11-27 06:02:37
问题 I Dispatch a action from one component this.store.dispatch({type : STORE_TEAMCREST , payload : team.crestURI}); and in the other component i select from the store using this.store.select(state => state.table.teamCrest).subscribe(data => this.teamCrest = data); This works fine if my app is going sequentially backward or forward, but once i do a browser refresh the state loses it's value. How to preserve it's value so that it works on browser refresh? 回答1: Your store has a subscribe function