代码之家  ›  专栏  ›  技术社区  ›  Mateusz Gebroski

NgRx调度行动生效并采取一个(?)

  •  0
  • Mateusz Gebroski  · 技术社区  · 7 年前

    @Effect()
    authSignin = this.actions$
        .pipe(
            ofType(AuthActions.TRY_SIGNIN),
            map((action: AuthActions.TrySignin) => {
                console.log('AuthEffects -> authSignin');
                return action.payload;
            }),
            switchMap((data: any) => {
                this.router.navigate(['/student']);
                const user: User = {
                    id: '1',
                    firstName: 'John',
                    lastName: 'Doe',
                    pesel: '19827364',
                    dateOfBirth: new Date(),
                    address: 'Canada, where clone syrup is made',
                    phoneNumber: '14 2345 345'
                }
                return [
                    { type: AuthActions.TRY_SIGNIN },
                    { type: UserActions.SET_USER, payload: user }
                ]
            })
        )
    

    所以问题又来了: 有没有办法只获取一次用户凭据的值,并留下常规行为来检查身份验证?

    任何暗示都会很有帮助。非常感谢。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Gabriel George    7 年前

    我认为在你的情况下,它将永远是在影响循环,最终会崩溃你的浏览器。你有什么理由派这个人去吗 AuthActions.TRY_SIGNIN 在一个正在听的效果里面 AuthActions.TRY\登录 也?

    推荐文章