This repository was archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Feature: NgBusy use within more complex piped operators #10
Copy link
Copy link
Open
Description
Is it (or would it be) possible to useng-busy with more complex RxJS operators like switchMap or exhaustMap on a BehaviorSubject without subscribing to an Observable within a subscribe block?
If you set busy on the BehaviorSubject it will always be busy. You also can't use tap to handle side effects either without unsubscribing in multiple places to handle edge cases since the ng-busy subscription wouldn't be directly related to the Http request.
public currentPage$ = new BehaviorSubject(1);
// ...
this.currentPage$
.pipe(
exhaustMap((page: number = 1) =>
(page) ? this.getAlerts(page) : empty()
),
map((response: HttpResponse<Alert[]>) =>
response.results
)
)
.subscribe(
(alerts: Alert[]) => { ... },
(error: any) => { ... }
);
As I understand it from articles on RxJS Observables don't like being within Observables, but this is the only way I can see how to accomplish this using ng-busy currently:
this.currentPage$
.subscribe(
(page: number = 1) => {
this.busy = this.getAlerts(page)
.pipe(
map((response: HttpResponse<Alert[]>) =>
response.results
)
)
.subscribe(
(alerts: Alert[]) => { ... },
(error: any) => { ... }
);
},
(error: any) => { ... }
);
Metadata
Metadata
Assignees
Labels
No labels