angular observable async code example
Example 1: await on observable
if (condition) {
await observable.first().toPromise();
}
Example 2: await on observable
await observable.toPromise();
Example 3: why async pipe should be used in angular
Async pipe automatically unsubscribes the observable thus saving some lines of code
Async pipe utilizes on push change detection strategy which is good for performance.