问题是api.deleteUser
返回 null(状态 204),所以用户丢失了。如何将用户(即action.payload
)传递给DeleteUserSuccess(user)
?
@Effect()
public deleteUser$: Observable<Action> = this._actions$
.ofType(DELETE_USER_PENDING)
.pipe(
switchMap((action: IAction<User>) =>
this.api.deleteUser((action.payload as User).id)),
map((user: User) => new DeleteUserSuccess(user)),
catchError((err: Error, caught: Observable<Action>) => {
console.log(err);
return caught;
})
);