I would like to dispatch two actions in one effect. Currently I have to declare two effects to achieve this :
// first effect
@Effect()
action1$ = this.actions$
.ofType(CoreActionTypes.MY_ACTION)
.map(res => {
return { type: "ACTION_ONE"}
})
.catch(() => Observable.of({
type: CoreActionTypes.MY_ACTION_FAILED
}));
// second effect
@Effect()
action2$ = this.actions$
.ofType(CoreActionTypes.MY_ACTION)
.map(res => {
return { type: "ACTION_TWO"}
})
.catch(() => Observable.of({
type: CoreActionTypes.MY_ACTION_FAILED
}));
Is it possible to have one action, be the source of two actions via a single effect?
catch
composed where it is in your effect, if an error occurs, the observable will complete and your effect will cease to work. See this answer. – cartant