mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-12 13:07:17 +01:00
Add observeNavigation in ViewModel
This commit is contained in:
parent
c09964dc30
commit
61ce2f9e3d
@ -58,6 +58,14 @@ export class ViewModel<O extends Options = Options> extends EventEmitter<{change
|
|||||||
return this._options[name];
|
return this._options[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
observeNavigation(type: string, onChange: (value: true | string, type: string) => void) {
|
||||||
|
const segmentObservable = this.navigation.observe(type);
|
||||||
|
const unsubscribe = segmentObservable.subscribe((value: true | string) => {
|
||||||
|
onChange(value, type);
|
||||||
|
})
|
||||||
|
this.track(unsubscribe);
|
||||||
|
}
|
||||||
|
|
||||||
track<D extends Disposable>(disposable: D): D {
|
track<D extends Disposable>(disposable: D): D {
|
||||||
if (!this.disposables) {
|
if (!this.disposables) {
|
||||||
this.disposables = new Disposables();
|
this.disposables = new Disposables();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user