Skip to content

useViewModelDependency

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

This hook has multiple overloads.


Resolves the requested view model dependency and subscribes to it for changes.

This is a utility hook providing the following functionality.

const viewModel = useDependency(viewModelDependency);
useViewModel(viewModel);
function useViewModelDependency<TViewModel extends INotifyPropertiesChanged>(
  viewModelDependency: ResolvableSimpleDependency<TViewModel>
): TViewModel

Source reference: src/dependencies/UseViewModelDependency.ts:30.

Generic Parameters

Parameters

Returns: TViewModel

Returns the resolved view model which is also watched for changes.

See also


Resolves the requested complex view model dependency and subscribes to it for changes.

This is a utility hook providing the following functionality.

const viewModel = useDependency(viewModelDependency, additionalDependencies);
useViewModel(viewModel);
function useViewModelDependency<TViewModel extends INotifyPropertiesChanged, TAdditional extends readonly any[]>(
  viewModelDependency: ComplexDependency<TViewModel, TAdditional>,
  additionalDependencies: TAdditional
): TViewModel

Source reference: src/dependencies/UseViewModelDependency.ts:57.

Generic Parameters

  • TViewModel - The view model type to resolve.

    Type constraints: INotifyPropertiesChanged.

  • TAdditional - A tuple representing additional parameters required by the constructor.

    Type constraints: readonly any[].

Parameters

  • viewModelDependency: ComplexDependency<TViewModel, TAdditional>
    The view model dependency to resolve.

  • additionalDependencies: TAdditional
    Additional constructor arguments which also act as dependencies, if one of them changes the view model will be reinitialized.

Returns: TViewModel

Returns the resolved view model which is also watched for changes.

See also

Clone this wiki locally