使用ng-busy时遇到问题。我的组件中有4或5个订阅。当我运行一个时,它们可以正常工作,但是当我同时运行所有时,订阅会彼此等待退订。简而言之,当所有方法结束其请求时,将显示加载组件。
NgBusyModule配置如下:
NgBusyModule.forRoot(
new BusyConfig({
message: 'Please wait...',
backdrop: true,
template: BusyComponent,
delay: 0,
minDuration: 0,
wrapperClass: 'eng-busy'
})
)
组件如下所示:
ngOnInit() {
this.getWorkPlaces();
this.getPension();
}
getWorkPlaces() {
this.workPlaceSubscription = this.cabinetService.getContracts().subscribe(
workPlaces=> {
this.workPlaces = workPlaces;
}
)
}
getPension() {
this.pensionSubscription = this.cabinetService.getPension().subscribe(
pension=> {
this.pension = pension;
}
)
}
HTML:
<div class="cabinet-data">
<div [ngBusy]="workPlaceSubscription">
workPlaces data
</div>
<div [ngBusy]="pensionSubscription">
pension data
</div>
</div>
如何将订阅配置为互不依赖?