在NgRx中存储Firestore文档参考会引发错误

问题描述

我正在使用Ionic,Angular,Firebase和NgRx创建一个项目,当我尝试将文档引用存储在NgRx存储中时遇到问题。

我的代码:

组件

loginUser() {
  let loginFormValue = this.loginForm.value;
  this.authStore.dispatch(login({
    email: loginFormValue.email,password: loginFormValue.password,rememberMe: loginFormValue.rememberMe
  }));
}

效果

login$ = createEffect(() => {
  return this.actions$.pipe(
    ofType(login),switchMap((action) => {
      return this.authenticationService.loginUserByEmail(action.email,action.password,action.rememberMe).pipe(
          map((user) => {
            return loginSucceeded({ user });
          }),catchError((message) => {
            return of(loginFailed({ message }));
          })
      );
    })
  );
});

服务

loginUserByEmail(email: string,password: string,rememberMe: boolean): Observable<User> {
  let persistence = rememberMe ? auth.Auth.Persistence.LOCAL : auth.Auth.Persistence.NONE;
  return new Observable( (observer: Subscriber<User>) => {
    this.angularFireAuth.setPersistence(persistence).then(() => {
      this.angularFireAuth.signInWithEmailAndPassword(email,password).then((userCredential: auth.UserCredential) => {
        this.angularFirestore.collection('users').doc(userCredential.user.uid).get().toPromise().then((doc: DocumentSnapshot<DocumentData>) => {
          let data: DocumentData = doc.data();
          if (data) {
            data.id = uid;
            data.ref = doc.ref;
          }
          observer.next(data);
          observer.complete();
         });
      });
    });
  });
}

从文档中获取实际数据后,您将看到ref存储在实际数据上,以备后用。此外,此数据还包含对其他文档的其他引用。

因此,我实际上是从具有所有属性(包括ref属性)的服务中获取用户文档,但是在分派loginSucceeded操作之后,此错误在控制台中抛出:Cannot read property 'ignoreUndefinedProperties' of undefined

我没有找到解决方案/解决方法。

希望您能帮助我,谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)