mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-18 08:20:13 +01:00
refactor: improve observable layout change sharing
This commit is contained in:
parent
5cc4c19cee
commit
f0d84a6485
1 changed files with 5 additions and 5 deletions
|
|
@ -1,20 +1,20 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { delay, share } from 'rxjs/operators';
|
import { delay, shareReplay } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LayoutService {
|
export class LayoutService {
|
||||||
|
|
||||||
protected layoutSize$ = new Subject();
|
protected layoutSize$ = new Subject();
|
||||||
|
protected layoutSizeChange$ = this.layoutSize$.pipe(
|
||||||
|
shareReplay({ refCount: true }),
|
||||||
|
);
|
||||||
|
|
||||||
changeLayoutSize() {
|
changeLayoutSize() {
|
||||||
this.layoutSize$.next();
|
this.layoutSize$.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeLayoutSize(): Observable<any> {
|
onChangeLayoutSize(): Observable<any> {
|
||||||
return this.layoutSize$.pipe(
|
return this.layoutSizeChange$.pipe(delay(1));
|
||||||
share(),
|
|
||||||
delay(1),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue