You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which @angular/* package(s) are relevant/releated to the feature request?
core
Description
Subscribing to an Observable and using the result in view context requires the use of *ngIf and the async pipe. If you want to display content BEFORE the Observable emits a value you are left with using something like else anotherTemplate. This solves some cases, but is very limiting. Sometimes you actually want to display the content within. For example you could create a component LoadingIndicaterOverlayWrapper that greys out the actual content until a value arrives. This is not possible with *ngIf and the async pipe, since the ngIf is falsey until it emits.
Which @angular/* package(s) are relevant/releated to the feature request?
core
Description
Subscribing to an Observable and using the result in view context requires the use of *ngIf and the async pipe. If you want to display content BEFORE the Observable emits a value you are left with using something like else anotherTemplate. This solves some cases, but is very limiting. Sometimes you actually want to display the content within. For example you could create a component LoadingIndicaterOverlayWrapper that greys out the actual content until a value arrives. This is not possible with *ngIf and the async pipe, since the ngIf is falsey until it emits.
Proposed solution
See how NGRX resolves this issue with their ngrxLet directive: https://ngrx.io/guide/component/let
Vanilla Angular could profit from something similar imo.
Alternatives considered
At the moment you can use the dirty trick of using an object within *ngIf, so that it always resolves to truthy, but that is a bit messy and seems like a work around.
Source
https://medium.com/@yurykatkov/how-to-avoid-multiple-async-pipes-in-angular-ff0d51a8d368
The text was updated successfully, but these errors were encountered: