Search code examples
angularreduxngrxngrx-store

In NGRX, how do I chain actions from different reducers?


In my Angular/NGRX application I have two reducers, reducerA and reducerB.

  • reducerA retrieves a user ID;
  • In reducerB i have an action called GET_ALL_POSTS.

How can I wait for reducerA to resolve before calling reducerB.


Solution

  • Assuming you are doing this with an effect, you could map the GET_ALL_TRANSACTIONS action when the first one finishes. eg.

    retrieveUserId.pipe(
       switchMap((userId) => {
           new GET_ALL_TRANSACTIONS()
       })
    )