Skip to content

useViewModelMemo

github-actions[bot] edited this page Dec 3, 2024 · 3 revisions
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.

Generic Parameters

Parameters

  • 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 to useMemo.

Returns: TViewModel

Returns the created view model instance.

Clone this wiki locally