Wednesday, 30 May 2018

Angular ngrx + Firebase OAuth action called but effect not

i have an issue with my oauth setup, when i logout with this effect:

@Effect()
  logout:  Observable<Action> = this.actions.ofType(UserActions.LOGOUT)
    .switchMap(() => Observable.of(this.afAuth.auth.signOut()))
    .map(() => new UserActions.GetUser())
    .catch(err => Observable.of(new UserActions.AuthError({error: err.message})));

Everything works fine and the UserActions.GetUser() is being called. Now if i try to log in with this effect and this firebase auth function:

@Effect()
  googleLogin: Observable<Action> = this.actions.ofType(UserActions.GOOGLE_LOGIN)
    .switchMap(() => Observable.fromPromise(this.loginWithGoogle()))
    .map(() => new UserActions.GetUser())
    .catch(err => Observable.of(new UserActions.AuthError({error: err.message})));

private loginWithGoogle() {
  return this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
}

The new UserActions.GetUser() is called and i can see it in the Redux DevTools, but the actual effect is not called, i put a lot of console.log's in there to see if i did something wrong in the function, but it isn't called at all and also i have a catch in the GetUser, but that's also not triggering.

Is there some issue with firebase in this case or am i stupid?



from Angular ngrx + Firebase OAuth action called but effect not

No comments:

Post a Comment