I'm trying to refactor a get http request. The code that I'm using now is getting the data from service and in the subscribe method also changing a boolean flag
this.eventsService.getEvents(this.pageSize, this.currentPage).subscribe(
(data) => {
this.busy = false
this.events = data.events
}
);
I've refactor to use Observable on my view, and this code looks this way now, component code:
const $results = this.eventsService.getEvents(this.pageSize, this.currentPage);
this.$events = $results.pipe(tap(() => { this.busy = false } ), map(data => data.events));
view code (nativescript) :
<ListView *ngIf="!busy" [items]="$events | async" ></ListView>
it does provide proper content in the view but the busy flag is not changed in the tap operator. Is it feasible to somehow change boolean in the pipe() ?
this.$results?$resultsor$events?busymust be false? (Your refactored code looks basically OK, so wondering if there is something else amiss?)