Я обновляю @ngrx/effects от 1.x до 2.x
В 1.x у меня есть доступ к дереву состояний:
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 }));
Теперь в 2.x это только дает мне действие. Есть ли способ получить доступ к дереву состояний? Или мне следует избегать такого использования, потому что это не очень хорошая практика?
constructor(private actions$: Actions) {}
@Effect() bar$ = this.actions$
.ofType(ActionTypes.FOO)
.map((obj: any) => {
console.log(obj); // here is action only
return obj.state.user.isCool // so it is wrong here
})
.distinctUntilChanged()
.filter(x => x)
.map(() => ({ type: ActionTypes.BAR }));