While considering different container templates, I noticed that some load data in the following way:
<ng-container *ngIf="!(loading$ | async); else tpl">
When the client is retrieving data (such as Post
instances), it will update the loading$
observable to emit false. Once the Observable<Post[]>
s are available, the observable will be set to true.
It seems like we could easily replace loading$
with posts$
, since the *ngIf
statement evaluates to false
until the Observable<Post[]>
is ready to emit.
Therefore, we may not actually need loading$
at all - using posts$
instead should suffice.
Once the posts$
Observable is prepared, the container will display the posts one by one like so:
<post *ngFor="let post of (post$ | async)" [post]="post"></post>