I am having some trouble chaining actions one after the other in an Effect that makes an HTTP-request.
Here's the Effect code:
export class UserEffects {
@Effect()
update$: Observable<Action> = this.actions$.ofType(user.USERCHANGE).pipe(
switchMap(data => this.authService.login(data['payload'])),
map(userInfo => new UserChangedAction(userInfo)),
tap(() => this.store.dispatch(
new LoginStateChangeAction(localStorage.getItem('token')))
)
);
constructor(private authService: AuthService, private actions$: Actions,
public store: Store<fromRoot.State>) {}
}
The problem is both the actions are being called simultaneously. The LoginStateChange action depends on UserChanged action to complete.
How can I achieve this?
Thanks!