### File

`src/lib/window-instance.service.ts`

### Index

###### Properties
Public Readonly loading$
###### Methods
Public attachLoading

### Methods

Public attachLoading
`attachLoading(loading$: Observable)`
Defined in src/lib/window-instance.service.ts:22
Parameters :
Name | Type | Optional
loading$ | `Observable<any>` | No
Returns : `void`

### Properties

Public Readonly loading$
Default value : `new ToggleSubject(false)`
Defined in src/lib/window-instance.service.ts:18

    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 ""