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 1/2] 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(); From e07abfa02a543f1ddc9515d039f3fe56f81b5b88 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Mon, 7 Mar 2022 11:33:51 +0530 Subject: [PATCH 2/2] Add missing type --- src/domain/ViewModel.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/domain/ViewModel.ts b/src/domain/ViewModel.ts index 04fec86e..8b8581ae 100644 --- a/src/domain/ViewModel.ts +++ b/src/domain/ViewModel.ts @@ -58,9 +58,9 @@ export class ViewModel extends EventEmitter<{change return this._options[name]; } - observeNavigation(type: string, onChange: (value: true | string, type: string) => void) { + observeNavigation(type: string, onChange: (value: string | true | undefined, type: string) => void) { const segmentObservable = this.navigation.observe(type); - const unsubscribe = segmentObservable.subscribe((value: true | string) => { + const unsubscribe = segmentObservable.subscribe((value: string | true | undefined) => { onChange(value, type); }) this.track(unsubscribe);