process manager, wait for another process manager

Author: beckendCreated Jul 10, 2016Updated Dec 9, 2025

I haven't figured out a way to wait for another process manager inside a process manager, store dispatch simply returns the action object which is of no use.

javascript

const fetchWhatEverManager = (action$, store) =>
  action$.ofType(FETCH_USER)
    .switchMap(action => {
      const maybeData = store.getState().getIn([ 'myReducer', 'myData' ]);
      if (!maybeData) {
        // Data has not been fetched to continue, need to fetch it right here
        // What to do here??? Dispatch does not wait for action
        const onlyActionObj = store.dispatch({ type: 'FETCH_MY_DATA_AND_POPULATE_REDUCER' });
      } else {
        // Did not need to fetch, do something with available data and return payload
        const payload = maybeData................
        return Observable.of({ type: 'MY_ACTION', payload });
      }
    });

Source: redux-observable/redux-observable