我为注册操作添加了新的效果,并出现以下错误:效果“ AuthEffects.register $”调度了无效的操作
所以,这是我的效果:
@Effect()
register$ = this.actions$.pipe(
ofType<Register>(AuthActionTypes.Register),
map(action => action.payload),
exhaustMap((register: RegisterModel) =>
this.authService
.register(register)
.pipe(
tap(status => new RegisterSuccess(status)),
catchError(error => of(new RegisterFailure(error)))
)
)
);
这是RegisterSuccess操作:
export class RegisterSuccess implements Action {
readonly type = AuthActionTypes.RegisterSuccess;
constructor(public payload: boolean) {}
}
它返回一个布尔值,表示是否成功注册。 这是减速器的情况:
case AuthActionTypes.RegisterSuccess: {
return {
...state,
error: null,
success: action.payload
}
}
问题出在哪里?效果看起来还可以,也可以采取行动,这是我的减速器出现问题吗? 谢谢!
答案 0 :(得分:1)
您的tap
应该是map
,以便返回操作。
@Effect()
register$ = this.actions$.pipe(
ofType<Register>(AuthActionTypes.Register),
map(action => action.payload),
exhaustMap((register: RegisterModel) =>
this.authService
.register(register)
.pipe(
map(status => new RegisterSuccess(status)),
catchError(error => of(new RegisterFailure(error)))
)
)
);