ngrx - 在 NgRX Effect 中处理时,效果将不再起作用
问题描述
对于我的生活,我无法弄清楚为什么一旦抛出并拦截错误,效果将不再起作用
@Effect()
register$ = createEffect(() => {
return this.actions$.pipe(
ofType(RegisterAction),
map(action => action.registrationInfo),
mergeMap(registrationInfo => {
return this.authService.createUser(registrationInfo.email, registrationInfo.password,
registrationInfo.lastname, registrationInfo.firstname);
}),
map(credentialInfo => ProfileInitAction({credentialInfo})),
catchError(error => [ProfileInitErrorAction(error)]),
);
});
解决方案
在 catchError 中添加 catch$ 似乎可以解决这个问题。
register$ = createEffect(() => {
return this.actions$.pipe(
ofType(RegisterAction),
map(action => action.registrationInfo),
mergeMap(registrationInfo => {
return this.authService.createUser(registrationInfo.email, registrationInfo.password,
registrationInfo.lastname, registrationInfo.firstname);
}),
map(credentialInfo => ProfileInitAction({credentialInfo})),
catchError((err, caught$) => {
notify(this.translate.instant('pages.auth.register.notify.error' + ': ' + err['message']), 'error');
return caught$;
}),
);
});
推荐阅读
- typescript - “...”[] 在打字稿中是什么意思?
- c# - 如何为 Azure 应用程序设置权限,以便应用程序可以访问站点及其驱动器?
- flutter - 在颤动中将对象转换为数组
- amazon-web-services - AWS DynamoDB 流:我可以将记录保存超过 24 小时吗?
- php - PHP:curl 脚本失败
- jquery - Gatsby JS:预加载器永远加载
- javascript - .map() 方法在项目之间打印“,”
- silverstripe - 从夹具文件生成的字段列表中的未知列
- python - Windows 上的 Visual Studio Code 远程 Python 调试
- javascript - Jquery脚本不适用于表单提交