ngrx-effects

NgRX Effect for downloading media file and dispatching progress; how to deal with the stream and throttling

南笙酒味 提交于 2019-12-06 07:30:28
I am struggling a bit with understanding and applying @Effects for my episode Download option. I got some help in another question and this is my latest concoction. Quick overview: User clicks download which dispatches a DOWNLOAD_EPISODE action which is captured in the first Effect. The download call returns a stream of HttpEvents and a final HttpResponse. During the event.type === 3 I want to report download progress. When event.type === 4 the body has arrived and I can call the success which for example can create a Blob. Service episodesService : download( episode: Episode ): Observable

Angular2 NGRX Performance Issues On Dispatch?

故事扮演 提交于 2019-12-06 06:08:40
I've been working on an application in Angular2/CLI/NGRX and things have been going well until recently. I'm noticing some pretty big spikes in performance especially with consecutive dispatches within the same container. For example lets say I have the following defined: public appEnvironment$: Observable<IEnvironment>; public assessment$: Observable<IAssessment>; public assessmentComments$: Observable<ICommentActivity[]>; public assessmentEvidence$: Observable<IEvidenceActivity[]>; public assessmentIssues$: Observable<IIssueActivity[]>; public assessmentSurvey$: Observable<ISurvey>; public

Is it possible to throw errors inside ngrx-effects without completing the Observable stream?

夙愿已清 提交于 2019-12-06 05:45:37
Is there any way to use throw with an Error object inside ngrx-effects streams without completing the stream? I've read these great answers on why the stream is being killed by throwing an error: @ngrx Effect does not run the second time ngrx effects error handling https://github.com/ngrx/platform/issues/646 My question is if I'm implementing the Angular ErrorHandler to catch errors, if I'm going to be able to use that with ngrx effects. @Effect() loginUserEffect: Observable<loginActions.Actions> = this.actions$ .ofType(loginActions.LOGIN_USER) .map((action: loginActions.LoginUser) => action

Ngrx effects on lower version of typescript doesn't work

試著忘記壹切 提交于 2019-12-06 05:01:55
I have an Ionic 3 App where I use ngrx/store and ngrx/effects . But each time I try to run the app it sais this error below: TypeScript Error A computed property name in a type literal must directly refer to a built- in symbol. ...: Cannot find name 'any'. which refers to this folder in my node modules node_modules/@ngrx/effects/src/on_run_effect.d.ts to this block of code below: export declare function isOnRunEffects(sourceInstance: { [onRunEffectsKey]?: onRunEffectsFn; }): sourceInstance is OnRunEffects; This can be fix by installing higher version of typescript but as of now currently I am

How to unit test this effect (with {dispatch: false})?

牧云@^-^@ 提交于 2019-12-05 17:28:51
问题 ngrx and unit testing beginner here. I have the following effect: @Injectable() export class NotificationEffects { @Effect({dispatch: false}) notificationShow$ = this.actions$ .ofType(notificationAction.NOTIFICATION_SHOW) .do((action: notificationAction.NotificationShowAction) => { this.notificationService.info(action.payload.config); }); constructor(private actions$: Actions, private notificationService: NotificationService) {} } Specifically, I would like to test that the

ngrx Effects: Are actions dispatched by one effect processed immediately by other effects?

十年热恋 提交于 2019-12-05 11:30:25
I have an Angular (2) app with four ngrx actions: START Not processed by the reducer (no state change) ngrx Effect calls an async task and maps to SUCCESS or ERROR SUCCESS Processed by the reducer ngrx Effect maps to ADVANCE ADVANCE Not processed by the reducer ngrx Effect navigates to a different route ERROR Processed by the reducer No Effect The problem is that the Effect that catches ADVANCE seems to run before the reducer that processes SUCCESS Here's the Effects code: @Effect() start$ = this.actions$ .ofType('START') .map(toPayload) .switchMap(input => doAsyncTask(input) .map(result => (

Wrap an API function in an RxJs Observable

╄→гoц情女王★ 提交于 2019-12-05 08:15:48
I am a newbie to RxJs and I have an API that I am using for geocoding that provides a function like the following: simpleGeocode(options) * where options = { address: {addr: ... }, success: Function, failure: Function}. The success function returns the geocoded LatLon object. I am using this in Angular app with NGRX Effects and so I would like it to have it as an Observable so I can use the standard Effect setup like: @Effect() public calculateLocation: Observable<void> = this.actions .ofType(actions.CALCULATE_LOCATION) .switchMap((action) => { let location = action.payload; let options = {

ngrx effect not being called when action is dispatched from component

ε祈祈猫儿з 提交于 2019-12-04 16:22:48
问题 I am having an issue with the ngrx store not dispatching an action to the effect supposed to deal with it. Here is the component that tries to dispatch: signin() { this.formStatus.submitted = true; if (this.formStatus.form.valid) { this.store.dispatch(new StandardSigninAction(this.formStatus.form.value.credentials)); } } The actions: export const ActionTypes = { STANDARD_SIGNIN: type('[Session] Standard Signin'), LOAD_PERSONAL_INFO: type('[Session] Load Personal Info'), LOAD_USER_ACCOUNT:

Angular router guard and ROUTER_NAVIGATION effect order

房东的猫 提交于 2019-12-04 11:44:29
There is a simple (Angular 4) route guard, which waits for some data to be loaded from backend: @Injectable() export class ContractsLoadedGuard implements CanActivate { constructor(private store: Store<State>) { } waitForData(): Observable<boolean> { return this.store.select(state => state.contracts) .map(contractList => !!contractList) .filter(loaded => loaded) .take(1); } canActivate(): Observable<boolean> { return this.waitForData(); } } Routing: const routes: Routes = [ { path: 'app-list', canActivate: [ContractsLoadedGuard], component: AppListComponent }, ]; And finally there is an @ngrx

ngrx effect not being called when action is dispatched from component

ぃ、小莉子 提交于 2019-12-03 10:31:11
I am having an issue with the ngrx store not dispatching an action to the effect supposed to deal with it. Here is the component that tries to dispatch: signin() { this.formStatus.submitted = true; if (this.formStatus.form.valid) { this.store.dispatch(new StandardSigninAction(this.formStatus.form.value.credentials)); } } The actions: export const ActionTypes = { STANDARD_SIGNIN: type('[Session] Standard Signin'), LOAD_PERSONAL_INFO: type('[Session] Load Personal Info'), LOAD_USER_ACCOUNT: type('[Session] Load User Account'), RELOAD_PERSONAL_INFO: type('[Session] Reload Personal Info'), CLEAR