I want to check if the user is a new user and then navigate to the appropriate route .
I am using router resolve for the same but the problem is the sooner i push to the Observable it is subscribed again rendering the check useless . please help
``` resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable ```
this.users = this.db.list('/users') as FirebaseListObservable
this.afAuth.authState.subscribe((data) => {
console.log("data" + JSON.stringify(data));
this.users.subscribe(users => {
let exists = users.some(function (el) {
return el.email === data.email;
});
//If email does not exists in the database i.e. New user
if (!exists) {
this.users.push({
email: data.email
}) // once i enter data to the user it triggers the subscription again how to push and stop subscribing here
this.router.navigate(['/cli']);
}
else {
// If user already exists
this.router.navigate(['/basic']);
}
});
});
}
Hi @rahulrsingh09, for general how-to questions like this, please use StackOverflow.
@markgoho it like a issue or a feature that i wanted to know about
this is not "like" an issue nor a request
this can be solved with just the firebase js sdk, no need for the observable extensions that we have written here
rough idea: ref("users/" + data.uid).once('value').then(user => if user { navigate } else { push+navigate })