当我使用此效果注销时,我的oauth设置存在问题:
@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})));
Run Code Online (Sandbox Code Playgroud)
一切正常,UserActions.GetUser()正在被召唤.现在,如果我尝试使用此效果和此firebase auth函数登录:
@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());
}
Run Code Online (Sandbox Code Playgroud)
新的UserActions.GetUser()被调用,我可以在Redux DevTools中看到它,但实际的效果没有被调用,我在那里放了很多console.log,看看我是否在函数中做错了,但它没有被调用一切,我也有一个catch在GetUser,但是这也不能触发.
在这种情况下是否存在firebase的问题或者我是愚蠢的?
操作:
获得用户效果:
@Effect()
getUser: Observable<Action> = this.actions.ofType(UserActions.GET_USER)
.switchMap(() => {
console.log('test'); // <-- Not called
return this.afAuth.authState;
})
.map(()=> {
return new UserActions.Authenticated();
});
Run Code Online (Sandbox Code Playgroud)
** …
observable firebase-authentication ngrx ngrx-effects angular
我想在 Firestore 中订购一个字段,它是一个字符串,但包含数字。我可以以某种方式指定订购方法或自定义吗?
** 编辑 1:
我得到的订单是这样的:
1 -> 10 -> 100 -> 101
但我想要:
1 -> 2 -> 3 -> 4