My problem is very similar to this one.
In foo.component.html
:
<ng-container *ngFor="let item of items">
<ng-container *ngIf="(fooFunc(item.property) | async) as element">
{{ element | json }}
</ng-container>
</ng-container>
In foo.component.ts
:
fooFunc(foo: any) {
return this.fooService.fooServiceFunc(foo).pipe(
take(1),
shareReplay(1)
);
}
The fooServiceFunc
in fooService
will return only one Observable
at one time.
My problem is that now my app fires infinite requests (after the whole items
array has been iterated, it will fire the request again from beginning, over and over), which seems to be a side-effect of async
pipe which is announced in this answer. But I still cannot figure out how to fix this?