angular - NgRx 效果 catchError 永远不会启动
问题描述
为什么我的 loginFailure 操作不起作用?当我通过不正确的密码 loginSuccess 操作触发并且用户变量包含错误数据。
login 是来自 firebase auth 的 Promise。
ofType(authActions.login),
switchMap(creditionals => from(this.userService.login(creditionals.email, creditionals.password)).pipe(
map( (user: User) => authActions.loginSuccess({ user })),
catchError(error => of(authActions.loginFailure({ error })))
)
)
), {
dispatch: true
});
actions
export const login = createAction(
'[Auth] Login',
props<{ email: string, password: string }>()
);
export const loginSuccess = createAction(
'[Auth] Login Success',
props<{ user: User }>()
);
export const loginFailure = createAction(
'[Auth] Login Failure',
props<{ error: any }>()
);
解决方案
推荐阅读
- r - 如何将二维矩阵的大小分配给 r 中的两个新变量?
- strapi - 如何让 Strapi 电子邮件插件显示在配置下拉列表中
- reactjs - 将 url 参数传递给私有路由_react Router
- android - 无法使用 mockwebserver 开始 Espresso 测试:无法解析 com.squareup.okhttp3:okhttp
- objective-c - iOS:我想连续旋转图像,但它不起作用
- java - 在为 spring mvc 运行以下代码时出现 http 404 错误。告诉我错误在哪里以及如何修复它?
- typescript - 声明模块导致 lint 错误“意外令牌,应为“{”
- android - 错误:无法解决 android studio 3.4 中的依赖关系
- javascript - JS:在`new Function(...)`中获取错误行号
- c - 有没有办法检查数组中字符串的大写和 isalpha 大小写?