angularngrxngrx-storengrx-effectsangular-ngrx-data

Actions not triggering subsequent actions


Github link to my sample program.

in file app.component.ts created a session expiry action which will be triggered once timeout happens

 timerExpiration : setTimeout(() => {
          this.store.dispatch(SessionActions.expirationTimerElapsed())
        }, 2000) as unknown as number  ,

once above action

in effect of SessionActions.expirationTimerElapsed is completed,

SessionActions.terminateSession action should be triggered

session.effects.ts

expiredTimer = createEffect(()=> 
    this.actions.pipe(
      ofType(SessionActions.expirationTimerElapsed),
      map(()=> SessionActions.terminateSession({reason :'TimeOut'}))
    )
  );

but SessionActions.terminateSession is not called.

Any idea what I'm doing wrong?


Solution

  • The effect needs to be registered in a module. For more info see the docs: https://ngrx.io/guide/effects#registering-root-effects