Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 14, 2024. It is now read-only.
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Feature: NgBusy use within more complex piped operators #10

Open
@mtpultz

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /