File

src/lib/window-instance.service.ts

Index

Properties
Methods

Methods

Public attachLoading
attachLoading(loading$: Observable)
Parameters :
Name Type Optional
loading$ Observable<any> No
Returns : void

Properties

Public Readonly loading$
Default value : new ToggleSubject(false)
import {
  Injectable,
  OnDestroy,
} from '@angular/core';
import {
  Observable,
  Subscription,
} from 'rxjs';
import {
  delay,
  map,
} from 'rxjs/operators';
import { ToggleSubject } from '@rxap/rxjs';

@Injectable()
export class WindowInstanceService implements OnDestroy {

  public readonly loading$ = new ToggleSubject(false);

  private readonly _attachedLoadingSubscription = new Subscription();

  public attachLoading(loading$: Observable<any>) {
    this._attachedLoadingSubscription.add(
      loading$.pipe(map(Boolean), delay(0)).subscribe(this.loading$.next),
    );
  }

  public ngOnDestroy() {
    this._attachedLoadingSubscription.unsubscribe();
  }

}

results matching ""

    No results matching ""