mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-19 08:50:13 +01:00
17 lines
427 B
TypeScript
17 lines
427 B
TypeScript
|
|
import {Injectable, OnDestroy} from '@angular/core';
|
||
|
|
import {Observable} from 'rxjs';
|
||
|
|
import {takeWhile} from 'rxjs/operators';
|
||
|
|
|
||
|
|
@Injectable()
|
||
|
|
export class CurrentThemeService implements OnDestroy {
|
||
|
|
alive = true;
|
||
|
|
|
||
|
|
readonly currentTheme$: Observable<any> = new Observable(subscriber => {
|
||
|
|
subscriber.next(localStorage.theme);
|
||
|
|
}).pipe(takeWhile(() => this.alive));
|
||
|
|
|
||
|
|
ngOnDestroy(): void {
|
||
|
|
this.alive = false;
|
||
|
|
}
|
||
|
|
}
|