From 61ce2f9e3d1a408d8c8f6b0494d5b0e0687d0beb Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Thu, 3 Mar 2022 15:36:25 +0530 Subject: [PATCH] Add observeNavigation in ViewModel --- src/domain/ViewModel.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/domain/ViewModel.ts b/src/domain/ViewModel.ts index cfe22326..04fec86e 100644 --- a/src/domain/ViewModel.ts +++ b/src/domain/ViewModel.ts @@ -58,6 +58,14 @@ export class ViewModel extends EventEmitter<{change 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(disposable: D): D { if (!this.disposables) { this.disposables = new Disposables();