@effect()
public loadAccommodations$: Observable = this.actions$
.ofType(PAA.PROPERTY_LOAD_REQUEST)
// .debounce(300)
// introducing this mitigates the flood but does not resolve the issue
.switchMap((action: Action) => {
return this.propertyAccommodationsService.loadAccommodations(action.payload.id)
.takeUntil(this.loadAccommodations$)
.map((response: IResponseSuccess) => PAA.loadSuccess(action.payload, response))
.catch((error: Error) => {
const errorNotification = errorNotificationFactory(error.message);
this.notificationService(errorNotification)
return of( PAA.loadFailure() );
});
});
After dispatch PAA.PROPERTY_LOAD_REQUEST only once my effect intercepts this action many times until Maximum call stack size exceeded.
Versions: "angular/core": "2.4.6",
"@ngrx/core": "^1.2.0",
"@ngrx/store": "^2.2.1",
"@ngrx/effects": "^2.0.1",
"rxjs": "5.0.2",
Note: effects are registered only once in app.module.
An
@Effect
does dispatch an Action itself. Your Effect dispatches the same Action again and again until either the call-stack is exeeded or the call returns.You need to add
dispatch: false
to the Effect decorator:Or you dispatch another action: