forked from mystiq/hydrogen-web
Merge pull request #700 from vector-im/ajbura-patch-2
Add observeNavigation in ViewModel
This commit is contained in:
commit
88482292e1
1 changed files with 8 additions and 0 deletions
|
@ -58,6 +58,14 @@ export class ViewModel<O extends Options = Options> extends EventEmitter<{change
|
|||
return this._options[name];
|
||||
}
|
||||
|
||||
observeNavigation(type: string, onChange: (value: string | true | undefined, type: string) => void) {
|
||||
const segmentObservable = this.navigation.observe(type);
|
||||
const unsubscribe = segmentObservable.subscribe((value: string | true | undefined) => {
|
||||
onChange(value, type);
|
||||
})
|
||||
this.track(unsubscribe);
|
||||
}
|
||||
|
||||
track<D extends Disposable>(disposable: D): D {
|
||||
if (!this.disposables) {
|
||||
this.disposables = new Disposables();
|
||||
|
|
Loading…
Reference in a new issue