首页 > 解决方案 > 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 }>()
);

标签: angularauthenticationngrxangularfire

解决方案


推荐阅读