我们如何用 Angular 中的 createEffect 替换 Effect 代码来进行日志记录?
任何人都可以帮我解决如何使用 createEffect 转换下面的效果代码吗?据我们所知,该效果已被弃用。
@Effect()
LogIn: Observable<any> = this.actions.pipe(
ofType(AuthActionTypes.LOGIN)
.map((action: LogIn) => action.payload)
.switchMap((payload: any) => {
return this.authService.logIn(payload.email, payload.password).
.map((user: any) => {
console.log(user);
return new LogInSuccess({token: user.token, email: payload.email});
})
.catch((error: any) => {
console.log(error);
// return Observable.of(new LogInFailure({ error: error }));
});
}));
提前致谢 !! 注意* :- 我正在使用下面的文档 https://mherman.org/blog/authentication-in-angular-with-ngrx/
Can anyone please help me out with how I can convert below Effect code with createEffect? As we know that effect is already deprecated.?
@Effect()
LogIn: Observable<any> = this.actions.pipe(
ofType(AuthActionTypes.LOGIN)
.map((action: LogIn) => action.payload)
.switchMap((payload: any) => {
return this.authService.logIn(payload.email, payload.password).
.map((user: any) => {
console.log(user);
return new LogInSuccess({token: user.token, email: payload.email});
})
.catch((error: any) => {
console.log(error);
// return Observable.of(new LogInFailure({ error: error }));
});
}));
Thanks in Advance !!
NOTE* :- I am using below doc for this https://mherman.org/blog/authentication-in-angular-with-ngrx/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)