viewModel

@Composable
inline fun <VM : ViewModel> viewModel(tag: String? = null): VM

Deprecated

Use the new Compose Multiplatform rememberViewModel instead from Kodein Framework Compose

Replace with

import org.kodein.di.compose.viewmodel
rememberViewModel

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.


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

Deprecated

Use the new Compose Multiplatform rememberViewModel instead from Kodein Framework Compose

Replace with

import org.kodein.di.compose.viewmodel
rememberViewModel

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.

A

The type of argument the returned factory takes.

argType

The type of argument the returned factory takes.

arg

A function that returns the argument that will be given to the factory when curried.

Throws

DI.NotFoundException

If no provider was found.

DI.DependencyLoopException

If the value construction triggered a dependency loop.