src/lib/window-instance.service.ts
Properties |
|
Methods |
|
| Public attachLoading | ||||||
attachLoading(loading$: Observable
|
||||||
|
Defined in src/lib/window-instance.service.ts:22
|
||||||
|
Parameters :
Returns :
void
|
| 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();
}
}