takeUtil
with a Subject to manage unsubscribing, do you have to call subject.complete()
? I saw somewhere that you don't, but I am wondering why or why not? Can you explain this or point me to an article that speaks specifically about the complete()
call on that subject and why it would (or wouldn't) be needed?
takeUtil
in fact will unsubscribe upstream and complete downstream.complete
and when it doesn't matter and why. Take a look if interested: https://stackoverflow.com/questions/57007118/do-i-need-to-complete-takeuntil-subject-inside-ngondestroy
this.beds$ = this.wrcService.getWrcBedsByFilter(this.wrcId, workerTypeId, blockId, buildingId, floorId, ['100000002'])
.pipe(
tap(bedsResponse => console.log(bedsResponse)),
filter(bedsResponse => bedsResponse != null),
flatMap(beds => beds),
map(bed => {
bed.numberOfBedsArray = Array.from({length: bed.qty}, (v, i) => i + 1);
return bed;
}),
mergeMap(beds => beds)
);
bedsResponse
is of type Observable<Bed[]>
flatting
it to each Bed object
this.wrcService.getWrcBedsByFilter().pipe(map(beds => beds.map(...)))
should be enough right?