I have an Observable
called leadChanged$
, which I can easily connect to the template using the async
pipe.
leadChanged$: Observable<LeadModel>;
this.leadChanged$ = this.leadsDataService.leadChanged$.pipe(
map((res) => ({
...res,
alert: { ...res.alert, transcript: highlightKeywordsLeadFunction(this.lead) },
}))
);
However, there is additional logic now where I need to handle the situation when res?.isManualLead
is present. Is it possible to achieve this without using a subscribe
method? I still want to continue utilizing the async
pipe in this case.
leadChanged: LeadModel;
this.leadsDataService.leadChanged$
.subscribe((res) => {
if (res?.isManualLead) {
this.leadChanged = {
...res,
};
} else {
this.leadChanged = {
...res,
alert: { ...res.alert, transcript: highlightKeywordsLeadFunction(this.lead) },
};
}
});