【发布时间】:2021-11-30 00:03:31
【问题描述】:
我有这种Observable,我可以轻松地使用模板上的async 管道。
leadChanged$: Observable<LeadModel>;
this.leadChanged$ = this.leadsDataService.leadChanged$.pipe(
map((res) => ({
...res,
alert: { ...res.alert, transcript: highlightKeywordsLeadFunction(this.lead) },
}))
);
但是由于额外的逻辑,现在我需要在上面这样写:逻辑是res?.isManualLead。你知道如何在没有subscribe 的情况下使用它吗?即我也想在这里使用async 管道。
leadChanged: LeadModel;
this.leadsDataService.leadChanged$
.subscribe((res) => {
if (res?.isManualLead) {
this.leadChanged = {
...res,
};
} else {
this.leadChanged = {
...res,
alert: { ...res.alert, transcript: highlightKeywordsLeadFunction(this.lead) },
};
}
});
【问题讨论】:
标签: angular typescript ionic-framework rxjs