I am struggling to figure out how to fire multiple actions in a catch
error handler in my epics.
I have successfully figured out how to fire multiple actions on a successful async call in my epics using the thunk-middleware. See below:
const editDomainsEpic = (action$) =>
action$
.ofType(EDIT_DOMAINS)
.mergeMap((action) =>
Rx.Observable.fromPromise(api.editDomains(action.payload))
// Here we are using Redux thunk middleware to execute
// a function instead of just dispatching an action
// so that we can disptach two actions
// ----------------- vvv
.map((domain) => (dispatch) => {
// Display Growl Notifications
dispatch(
displayGrowlNotification(
MESSAGE_TYPES.SUCCESS,
`${domain.name} was saved`
)
)
// Fire Success Action
dispatch({
type: EDIT_DOMAINS_SUCCESS,
payload: { domain }
})
})
.catch((error) => Rx.Observable.of({
type: EDIT_DOMAINS_ERROR,
payload: { error }
}))
.takeUntil(action$.ofType(EDIT_DOMAINS_CANCEL))
)
Can anyone guide me to how I can have the catch
return or fire two observable actions that will get dispatched similarly to how I did with the success?