When working in JS, there is a clever method for assigning values from an array to new variables with ease:
let [a, b, c] = [1, 2, 3]; // a = 1, b = 2, c = 3
I started thinking about whether I could achieve a similar elegant solution using Angular's HTML syntax, possibly like this:
// TS
this.obs1$: Observable<ObsType1> = ...;
this.obs2$: Observable<ObsType2> = ...;
this.combined$ = combineLatest(this.obs1$, this.obs2$);
// HTML
<div *ngIf="combined$ | async as [valOfObs1, valOfObs2]">
...
</div>
The observable combined$
that I am utilizing is the result of the combination operator known as combineLatest from RxJS, which should provide me with an array of values derived from different arrays.