Skip to content

useViewModel

github-actions[bot] edited this page Dec 3, 2024 · 3 revisions
API / useViewModel hook

This hook has multiple overloads.


Watches the given view model for property changes.

function useViewModel<TViewModel extends undefined | null | INotifyPropertiesChanged>(
  viewModel: TViewModel
): TViewModel

Source reference: src/hooks/UseViewModel.ts:22.

Generic Parameters

Parameters

  • viewModel: TViewModel
    The view model to watch.

Returns: TViewModel

Returns the provided view model instance.


Creates a new instance of a view model of the given type and watches for property changes.

function useViewModel<TViewModel extends INotifyPropertiesChanged>(
  viewModelType: ViewModelType<TViewModel, []>
): TViewModel

Source reference: src/hooks/UseViewModel.ts:30.

Generic Parameters

Parameters

  • viewModelType: ViewModelType<TViewModel, []>
    The view model class declaration to instantiate.

Returns: TViewModel

Returns the created view model instance.


Creates a new instance of a view model of the given type and watches for property changes, constructor arguments act as dependencies.

function useViewModel<TViewModel extends INotifyPropertiesChanged, TConstructorArgs extends readonly any[]>(
  viewModelType: ViewModelType<TViewModel, TConstructorArgs>,
  constructorArgs: TConstructorArgs
): TViewModel

Source reference: src/hooks/UseViewModel.ts:40.

Generic Parameters

Parameters

  • viewModelType: ViewModelType<TViewModel, TConstructorArgs>
    The view model class declaration to instantiate.

  • constructorArgs: TConstructorArgs
    The constructor arguments used for initialization, whenever these change a new instance is created.

Returns: TViewModel

Returns the created view model instance.

Clone this wiki locally