After reaching to tons of previous related questions here and on many other sites, I still cannot understand if I am writing an anti-pattern with the following code:
function signUp(email: string, password: string): Observable<UserCredential> {
return from(
createUserWithEmailAndPassword(email, password).then(
(authRes) => {
createNewUserDocument(authRes);
return authRes;
}
)
);
}
The createNewUserDocument is an async function. The point is I want to call it after the user signs up, and I want to return an Observable<UserData> not Observable<Promise<UserData>> (nor Promise<UserData>), hence I cannot make the signup function async and just use 2 await calls sequentially.
Also, should I put async before then's handler and await before the createNewUserDocument call, or is it not necessary? (code seems to work as it is)