rememberViewModel

@Composable
inline fun <VM : ViewModel> rememberViewModel(tag: Any? = null): ViewModelLazy<VM>
@Composable
inline fun <A : Any, VM : ViewModel> rememberViewModel(tag: Any? = null, arg: A): ViewModelLazy<VM>

Gets an instance of a VM as an android ViewModel for the given tag.

VM generic will be preserved!

Return

An instance of VM.

Parameters

VM

The type of the ViewModel to retrieve.

tag

The bound tag, if any.

Throws

DI.NotFoundException

If no provider was found.

DI.DependencyLoopException

If the value construction triggered a dependency loop.