I'm having trouble dispatching multiple actions in the following effect:
@Effect()
someEffect$ = this.actions$.pipe(
ofType(someAction: Actions),
mergeMap(
(action)=>{
return this.authService.getProfile(action.payload.authInfo).pipe(
map((response: any) => {
if (response.isErrorResponse) {
return new HeaderActions.AuthFail(response);
} else {
//here i'd like to return multiple actions
return [
new HeaderActions.FetchMPInfoSuccess(this.fetchMpInfoSuccesState(getMpProfileResponse)),
new HeaderActions.GetAccountStates(true)
]
}
}),
catchError((error:HttpErrorResponse )=>{
return of(new HeaderActions.AuthFail(response));
})
);
}
)
);
I've tried adding an array of actions, in the return block, but that's giving an error that im not sending a valid action, any idea what i'm doing wrong?
that's not working← See "It's not working" is not helpful, specifically point 3 and 4.if (response.isErrorResponse)← that should not have to be checked here, make sure you are building restful APIs that return error status codes on failure. 2. The additional actions you want to execute should not be started inmap, use switchMap instead and you can execute the actions simultaneously usingforkJoin