I am currently in the process of migrating my code from version 1.x to 2.x of @ngrx/effects.
Previously, in version 1.x, I was able to access the state tree directly within an effect:
constructor(private updates$: StateUpdates<AppState>) {}
@Effect() bar$ = this.updates$
.whenAction(Actions.FOO)
.map(obj => obj.state.user.isCool)
.distinctUntilChanged()
.filter(x => x)
.map(() => ({ type: Actions.BAR }));
However, with the upgrade to version 2.x, I have noticed that now only the action is provided. Is there still a way for me to obtain access to the state tree within the effect? Or should I consider avoiding this approach as it may not be best practice anymore?
constructor(private actions$: Actions) {}
@Effect() bar$ = this.actions$
.ofType(ActionTypes.FOO)
.map((obj: any) => {
console.log(obj);
return obj.state.user.isCool
})
.distinctUntilChanged()
.filter(x => x)
.map(() => ({ type: ActionTypes.BAR }));