useViewModel - Andrei15193/react-model-view-viewmodel GitHub Wiki
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:21
.
-
TViewModel - The type of view model.
Type constraints:
undefined
|null
| INotifyPropertiesChanged.
-
viewModel: TViewModel
The view model to watch.
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:29
.
-
TViewModel - The type of view model.
Type constraints: INotifyPropertiesChanged.
-
viewModelType: ViewModelType<TViewModel, []>
The view model class declaration to instantiate.
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:39
.
-
TViewModel - The type of view model.
Type constraints: INotifyPropertiesChanged.
-
TConstructorArgs - The constructor parameter types.
-
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 the created view model instance.