I am updating @ngrx/effects from 1.x to 2.x
In 1.x I have access of state tree in effect:
constructor(private updates$: StateUpdates
Another way is using .withLatestFrom(this.store)
. So the complete code is:
constructor(
private actions$: Actions,
private store: Store
) {}
@Effect() bar$ = this.actions$
.ofType(ActionTypes.FOO)
.withLatestFrom(this.store, (action, state) => state.user.isCool)
.distinctUntilChanged()
.filter(x => x)
.map(() => ({ type: ActionTypes.BAR }));