. , Angular , , - , loadAll(), HTTP-. , , . . , , (, ).
- , , foos: Foo[].
, Observable, :
private cached;
ngOnInit() {
this.cached = this.http.get(`api/foos`)
.map(response => response.json() as Foo[])
.publishReplay(1)
.refCount()
.take(1);
}
:
<div *ngFor="let foo of cached | async"></div>
, , - , .
, RxJS 5.4.0 shareReplay(1) .publishReplay(1).refCount().
, changeDetection, . . ChangeDetectionStrategy,