useViewModelMemo - Andrei15193/react-model-view-viewmodel GitHub Wiki
API / useViewModelMemo hook
Ensures a view models instance per component generated by the factory and watched for changes. Whenever the provided deps
change a new instance is created, similar to useMemo
.
function useViewModelMemo<TViewModel extends undefined | null | INotifyPropertiesChanged>(
viewModelFactory: ViewModelFactory<TViewModel>,
deps: DependencyList
): TViewModel
Source reference: src/hooks/UseViewModelMemo.ts:21
.
-
TViewModel - The type of view model to create.
Type constraints:
undefined
|null
| INotifyPropertiesChanged.
-
viewModelFactory: ViewModelFactory<TViewModel>
The view model factory callback for creating an instance. -
deps: DependencyList
Dependencies of the callback, whenever these change the callback is called again, similar touseMemo
.
Returns the created view model instance.