Skip to content

useViewModelType

Andrei Fangli edited this page Sep 3, 2023 · 2 revisions
API / useViewModelType<TViewModel> hook

DEPRECATED!

In future versions this hook will be removed, switch to useViewModel.


Ensures a unique instance per component of the given type is created and watches the view model for changes. Returns the view model instance.

function useViewModelType<TViewModel extends INotifyPropertiesChanged>(viewModelType: ViewModelType<TViewModel>, watchedProperties?: readonly (keyof TViewModel)[]): TViewModel

Template Parameters

Parameters

  • viewModelType: ViewModelType<TViewModel>, the view model type to initialize.
  • watchedProperties: readonly Array<keyof TViewModel>, optional, a render will be requested when only one of these properties has changed.

Returns: TViewModel

Returns the initialized view model instance, unique per component lifecycle.

Clone this wiki locally