ngrx中如何在dispatch中获取接口返回的状态?

this._store.dispatch(new AddUserAction(this.user));
我要在这里获取到code做进一步操作

Effects:
@Effect() addUser$ = this._actions$.pipe(

    ofType<UserAction.AddUserAction>(UserAction.UserActionTypes.ADD_USER),
    switchMap(data => {
        return this._userService.addUser(data.payLoad).pipe(
            map(res => {
                if (res.code === 200) {
                    return new UserAction.AddUserSuccessAction(res);
                } else {
                    return new UserAction.AddUserFailAction(res.code);
                }
            }),
            catchError(error => of(new UserAction.AddUserFailAction(error)))
        );
    })
);
阅读 1.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进