【发布时间】:2021-12-03 06:12:28
【问题描述】:
我有这个设置器,它分配一个可观察到的类成员systemAreasOptions$。我在那里这样做是因为它需要等待mappedItem$ 有一个不为空的发射。我最初在班级级别分配了systemAreasOptions$,但它没有等待mappedItem$。由于某种原因,在使用asyncPipe 时,我什至无法让 HTML 重新呈现。我如何告诉一个 observable (systemAreasOptions$) 等待另一个 observable (mappedItem$),而不是仅仅将它分配到另一个发出的位置?
public set mappedItem(mappedItem: IPermissionsMappedItem) {
mappedItem.hydrate$Permissions().then(_ => {
this.mappedItem$.next(mappedItem);
this.systemAreasOptions$ = from(
this.lookupService.SYSTEM_AREAS.toNestedLookup()
.$promise as unknown as Observable<IPermissmissionsLookup[]>
).pipe(
map(systemAreas => orderBy(systemAreas,systemArea => systemArea?.label?.toLowerCase())),
map(systemAreas => systemAreas.map(area => ({
...area,
permissions: this.getPermissionsForArea(area.id)
}))),
shareReplay(1),
tap(console.log)
);
this._subscriptions.add(
this.systemAreasOptions$.subscribe(
this.systemAreasOptionsBehaviourSubject$)
);
});
}
【问题讨论】:
标签: angular rxjs rxjs6 angular11