From 23a2785223332c6dcceda8fa0529d07928622a74 Mon Sep 17 00:00:00 2001 From: R Midhun Suresh Date: Sat, 26 Jul 2025 18:28:17 +0530 Subject: [PATCH] Provide a new interface for generic vm --- src/shared-components/ViewModel.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/shared-components/ViewModel.ts b/src/shared-components/ViewModel.ts index 9f088c4300..732f7c3013 100644 --- a/src/shared-components/ViewModel.ts +++ b/src/shared-components/ViewModel.ts @@ -21,3 +21,20 @@ export interface ViewModel { */ subscribe: (listener: () => void) => () => void; } + +/** + * The interface for a generic ViewModel passed to the shared components. + */ +export interface ViewModelNew { + /** + * Subscribes to changes in the view model. + * ViewModel will invoke the callback when the UI needs to be updated. + */ + subscribe: (callback: () => void) => () => void; + + /** + * React uses the return value of this method to determine if it needs to + * re-render the component. + */ + getSnapshot: () => unknown; +}