mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 15:40:11 +01:00
refactor: improve observable layout change sharing
This commit is contained in:
parent
b4b07f7e82
commit
2d75441977
1 changed files with 20 additions and 0 deletions
20
src/app/@core/utils/layout.service.ts
Normal file
20
src/app/@core/utils/layout.service.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable, Subject } from 'rxjs';
|
||||||
|
import { delay, shareReplay } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class LayoutService {
|
||||||
|
|
||||||
|
protected layoutSize$ = new Subject();
|
||||||
|
protected layoutSizeChange$ = this.layoutSize$.pipe(
|
||||||
|
shareReplay({ refCount: true }),
|
||||||
|
);
|
||||||
|
|
||||||
|
changeLayoutSize() {
|
||||||
|
this.layoutSize$.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangeLayoutSize(): Observable<any> {
|
||||||
|
return this.layoutSizeChange$.pipe(delay(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue