Skip to content

//reactivestate/com.ensody.reactivestate.android/stateViewModel

stateViewModel

[android]\ inline fun <T : ViewModel> Fragment.stateViewModel(crossinline provider: (handle: SavedStateHandle) -> T): Lazy<T>

inline fun <T : ViewModel> ComponentActivity.stateViewModel(crossinline provider: (handle: SavedStateHandle) -> T): Lazy<T>

Creates a ViewModel with a SavedStateHandle.

The provider should instantiate the ViewModel directly.

See also

reactiveState if you want to create multiplatform ReactiveState ViewModels.