mercredi 17 mars 2021

What can I do to stop circular dependency in angular?

Circular dependency detected error is preventing my application from being run on browser. I tried to stop it by making the "ShowCircularDependency"=false. But the problem is still there.

export class UserService {
constructor(private db: AngularFireDatabase, private authSvr: AuthService) { }
get AppUser$(): Observable<firebase.default.UserInfo> {
    return this.authSvr.user$.pipe(
      switchMap((user) => {
        if(user){
          return this.getUser(user.uid).valueChanges
        }
        else{
          return null
        }
    })
    )
  }
export class AuthService {

  user$ : Observable<firebase.User>;
  constructor(private afAuth: AngularFireAuth , private authSvr : UserService , private route : ActivatedRoute) {
      this.user$ = afAuth.authState;
  }
get AppUser$(): Observable<UserInfo> {
    return this.user$.pipe(
      switchMap((user) => {
        if(user){
          return this.authSvr.getUser(user.uid).valueChanges
        }
        else{
          return null
        }
    })
    )
  }
}



Aucun commentaire:

Enregistrer un commentaire