【发布时间】:2019-02-03 21:43:05
【问题描述】:
在下面的代码中,我从 Firestore 中获取了可观察到的集合长度。
getUserCartLength(uid:string){
return this.db.collection('users/'+uid+'/cart').valueChanges()
.pipe(
map(docs=>{return docs.length})
)
}
并且这个方法被@ngrx/effects 访问如下
@Effect()
userExist$ = this.actions$.ofType(UserAuthTypes.YES_USER_EXIST).pipe(
map((action:YesUserExist)=>action.user),
switchMap((user)=>{
return this.userService.getUserCartLength(user.uid)
.pipe(
map(length=>{
console.log(length);
return new InitializeUserCart(length);
})
)
}),
)
在组件中,我使用 store 方法在检查用户是否存在后调度操作
ngOnInit() {
this.logService.isUserExist().subscribe(user=>{
if(user) this.store.dispatch(new fromUser.YesUserExist(user));
else this.store.dispatch(new fromUser.NoUser());
})
}
只要用户登录,一切正常。当用户注销时,它会引发如下错误
core.js:1673 ERROR Error: Missing or insufficient permissions.
我对这个错误的理解是管道操作仍在尝试访问数据库
有什么方法可以关闭ngrx/effects中的管道操作或任何其他方法请帮助我!
【问题讨论】:
-
请不要将代码或错误作为图片发布。 meta.stackoverflow.com/questions/303812/…
标签: angular google-cloud-firestore ngrx-store ngrx-effects