ngrx

The package rxjs@5.0.0-beta.6 does not satisfy its siblings' peerDependencies requirements?

假如想象 提交于 2019-12-03 05:56:40
I am trying to install @ngrx/store module in my angular 2 app. I am using npm install and getting the following error: npm ERR! peerinvalid The package rxjs@5.0.0-beta.6 does not satisfy its siblings' peerDependencies requirements! npm ERR! peerinvalid Peer @angular/core@2.0.0-rc.0 wants rxjs@5.0.0-beta.6 npm ERR! peerinvalid Peer @angular/http@2.0.0-rc.0 wants rxjs@5.0.0-beta.6 npm ERR! peerinvalid Peer angular2@2.0.0-beta.16 wants rxjs@5.0.0-beta.2 npm ERR! peerinvalid Peer @ngrx/store@1.5.0 wants rxjs@5.0.0-beta.6 Does this mean I have to upgrade my angular2 module because it needs a lower

When to use ngrx/effect in angular2

扶醉桌前 提交于 2019-12-03 02:51:11
I have an anuglar2 project that communicates with an api. Recently, I decided to integrate ngrx/store to maintain the state of the components, and follow the dump-smart component architecture. But then while moving on, I read about ngrx/effect which can be used upon the api requests. And here my question comes, why should I use the ngrx/effect library, over just calling the corresponding function in my service from my container component to perform the api request and on success dispatch action to save the returned values in my store. If your case stays that simple, then you won't need an

Run ngrx/effect outside of Angular's zone to prevent timeout in Protractor

最后都变了- 提交于 2019-12-02 21:03:34
I just started to write e2e tests for my app and am running into timeout problems with Protractor and ngrx/effects. I have the following effect dispatching an action every couple of minutes: @Effect() setSessionTimer$ = this.actions$ .ofType(Auth.ActionTypes.SET_SECONDS_LEFT) .map(toPayload) .switchMap(secondsLeft => Observable.concat( Observable.timer((secondsLeft - 60) * 1000).map(_ => new Auth.SessionExpiringAction(60)), Observable.timer(60 * 1000).map(_ => new Auth.SessionExpiredAction()) )); Trying to run a Protractor test causes the test to timeout with the following error, since Angular

How to do http polling in ngrx effect

天涯浪子 提交于 2019-12-02 19:51:16
问题 I have this effect, and I'm trying to use timer to poll for data every x seconds. But I can't figure out how timer is supposed to interact with the data streams. I tried adding another switchMap to the top, but then I couldn't pass the action and payload to the second switchmap. Any ideas? I looked at this post but my situation is a little different. I'm passing a payload with my action that I need to access, and I'm using ngrx 6. @Effect() getData = this.actions$ .ofType(appActions.GET_PLOT

dispatch multiple actions in one effect

情到浓时终转凉″ 提交于 2019-12-02 19:00:59
I would like to diapatch two actions in one effect. Currently I have to declare two effects to achieve this : // first effect @Effect() action1$ = this.actions$ .ofType(CoreActionTypes.MY_ACTION) .map(res => { return { type: "ACTION_ONE"} }) .catch(() => Observable.of({ type: CoreActionTypes.MY_ACTION_FAILED })); // second effect @Effect() action2$ = this.actions$ .ofType(CoreActionTypes.MY_ACTION) .map(res => { return { type: "ACTION_TWO"} }) .catch(() => Observable.of({ type: CoreActionTypes.MY_ACTION_FAILED })); Is it possible to have one action, be the source of two actions via a single

How to do http polling in ngrx effect

大憨熊 提交于 2019-12-02 09:38:59
I have this effect, and I'm trying to use timer to poll for data every x seconds. But I can't figure out how timer is supposed to interact with the data streams. I tried adding another switchMap to the top, but then I couldn't pass the action and payload to the second switchmap. Any ideas? I looked at this post but my situation is a little different. I'm passing a payload with my action that I need to access, and I'm using ngrx 6. @Effect() getData = this.actions$ .ofType(appActions.GET_PLOT_DATA) .pipe( switchMap((action$: appActions.GetPlotDataAction) => { return this.http.post( `http://$

Using ngrx to obtain store's current state once

跟風遠走 提交于 2019-12-01 20:44:36
问题 Hi I was wondering if anyone know how to get a store's current state once without having to subscribe to it. I'm currently using ngrx to subscribe to the store and access its state to set a component's attribute, but since I'm subscribed this attribute is constantly refreshing. So I'm looking for a way to obtain this attribute just once so that I can display data without it refreshing constantly. Just in case, this happens inside my component's constructor. I've been trying something like

Why action doesn't trigger Effect the second time it runs?

余生颓废 提交于 2019-12-01 19:35:51
Effect: @Effect() loadDocsEffect$ = this.actions$.pipe( ofType(myActionTypes.LoadDocs), mergeMap(action => this.myService.getDocs()), map(data => new LoadDocsSuccess(data)), catchError(error => Observable.of(new LoadDocsFailure(error))) ); It works when I have data returned, but when the server responds with an error - 404 for example, the observable is complete and doesn't trigger the effect the second time I dispatch an action. I looked for a way to handle the error properly and to continue the observable stream so I could subscribe to it in my component and act accordingly. The solution in

Why action doesn't trigger Effect the second time it runs?

≡放荡痞女 提交于 2019-12-01 17:47:50
问题 Effect: @Effect() loadDocsEffect$ = this.actions$.pipe( ofType(myActionTypes.LoadDocs), mergeMap(action => this.myService.getDocs()), map(data => new LoadDocsSuccess(data)), catchError(error => Observable.of(new LoadDocsFailure(error))) ); It works when I have data returned, but when the server responds with an error - 404 for example, the observable is complete and doesn't trigger the effect the second time I dispatch an action. I looked for a way to handle the error properly and to continue

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