After calling setUsersData()
and addNewUser()
, they should return an Observable<void>
once their tasks are complete. Surprisingly, despite the code seeming to work correctly, the tap operator's function is not being executed as expected. The same issue persists even if I attempt to move the logic within the subscribe method. Any suggestions on why this might be happening?
this.userDataService.setUsersData().pipe(
take(1),
switchMap(() => {
if (name !== undefined) {
console.log('New User created');
return this.userDataService.addNewUser(resData.email, resData.localId, name);
} else {
console.log('Name is undefined. Skipping user creation.');
return of();
}
}),
tap(() => {
console.log('data setted');
this.isLoading = false;
this.router.navigate(['/microblog']);
})
).subscribe();
I've attempted to experiment with different RxJs operators, but unfortunately, it hasn't yielded any improvements.