I would like to ask about one thing.
Imagine you have Effect service class like that:
@Injectable()
export class GeneralEffect implements OnDestroy {
private state?: IAppState;
saveState$ = createEffect(() => this.actions$.pipe(
ofType(
logoutAction
),
tap((a) => {
console.log(this.state);
})
), {dispatch: false});
constructor(
private actions$: Actions,
private store: Store<IAppState>,
) {
this.store.select((state) => state).subscribe((s) => {
this.state = s;
});
}
}
My question is, is it guaranteed, that inside logoutAction effect the state will be updated? In other words, I know, that effect will be fired only after all reducers are finished (here), but does it also mean, that store select subscription (in constructor) will also be fired before effect, or there might be scenario, when inisde "tap" function, there will be still old State (before logoutAction reducer)?
I know, that one solution is to add withLatestFrom(this.store.select((state) => state)) into effects pipe, but I'm just curious how is it in order execution of Selectors observables and Effects.
Thanks