Reputation: 49924
I am trying to use Observable.if
in redux-observable to determine which action to dispatch.
In the case below, I expected it dispatch SIGN_OUT
. However, it does not dispatch any action.
How can I use it correctly? Thanks
export const initEpic = (action$, store) =>
action$
.ofType(INIT)
.mergeMap(() =>
Observable.if(
() => true,
{ type: SIGN_OUT },
{ type: START_SOMETHING }
));
Upvotes: 1
Views: 433
Reputation: 96959
The two parameters to Observable.if
should be Observables so you should be using it like:
Observable.if(
() => true,
Observable.of({ type: SIGN_OUT }),
Observable.of({ type: START_SOMETHING })
));
Upvotes: 1