I would like to call f2 after f1 has been completed. f1 function can be synchronous or asynchronous.
If
f1is synchronous, there is nothing special to do:
global() {
f1();
f2();
}
If
f1is asynchronous and return an Observable, useRxjs operator, like concatMap:
global() {
f1().concatMap(() => f2());
}
If
f1is asynchronous and return a Promise, useasync/await:
async global() {
await f1();
f2();
}
If
f1is asynchronous and return a Promise (alternative):
global() {
f1().then(res => f2());
}