-
Notifications
You must be signed in to change notification settings - Fork 2
useViewModel
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
.
-
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:30
.
-
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:40
.
-
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.
Overview
Motivation
Guides and Tutorials - Getting Started
Releases
CodeSandbox
API
Events
IEvent
IEventHandler
EventDispatcher
ViewModels
INotifyPropertiesChanged
ViewModel
Forms
Form
IFormFieldConfig
FormField
ReadOnlyFormCollection
FormCollection
IConfigurableFormCollection
FormSetupCallback
Validation
IValidator
ValidatorCallback
IObjectValidator
IValidatable
Validation / Triggers
WellKnownValidationTrigger
ValidationTrigger
Observable Collection
ReadOnlyObservableCollection
ObservableCollection
INotifyCollectionChanged
CollectionChangeOperation
INotifyCollectionReordered
CollectionReorderOperation
Observable Map
ReadOnlyObservableMap
ObservableMap
INotifyMapChanged
MapChangeOperation
Observable Set
ReadOnlyObservableSet
ObservableSet
INotifySetChanged
SetChangeOperation
Dependency Handling
IDependencyResolver
IDependencyContainer
DependencyContainer
useDependency
useViewModelDependency
useDependencyResolver
React Hooks
useViewModel
useViewModelMemo
useObservableCollection
useObservableMap
useObservableSet