Package-level declarations

Properties

Link copied to clipboard

The CompositionLocal containing the current SavedStateHandleFactory or null if not provided.

Link copied to clipboard

The CompositionLocal containing the current ViewModelStoreOwner or null if not provided.

Functions

Link copied to clipboard

Returns a sentinel DefaultCreationExtrasForAndroid for the current platform (Android). This is used to determine whether the user wants to use the default CreationExtras defined by the platform or not.

Returns the default CreationExtras for the current platform.

Returns EmptyCreationExtras for the current platform (non-Android).

Link copied to clipboard

Returns the nearest androidx.lifecycle.ViewModelStoreOwner that is provided via LocalViewModelStoreOwner. If it is not provided, then the androidx.lifecycle.ViewModelStoreOwner is searched in the hierarchy of Contexts. If no androidx.lifecycle.ViewModelStoreOwner is found, an IllegalStateException will be thrown.

Returns the default ViewModelStoreOwner for the current platform.

Remember a ViewModelStoreOwner in the current composition. It clears its ViewModelStoreOwner.viewModelStore when the current @Composable leaves the composition. Basically, its scope ties the lifecycle of the current composition.

Link copied to clipboard

Returns current composition local value for the ViewModelStoreOwner provided by LocalViewModelStoreOwner. or defaultPlatformViewModelStoreOwner if one has not been provided.

Link copied to clipboard
expect inline fun <VM : ViewModel> kmpViewModel(factory: ViewModelFactory<VM>, viewModelStoreOwner: ViewModelStoreOwner = defaultViewModelStoreOwner(), key: String? = null, extras: CreationExtras = defaultPlatformCreationExtras(), savedStateHandleFactory: SavedStateHandleFactory? = LocalSavedStateHandleFactory.current): VM
inline fun <VM : ViewModel> kmpViewModel(key: String? = null, viewModelStoreOwner: ViewModelStoreOwner = defaultViewModelStoreOwner(), extras: CreationExtras = defaultPlatformCreationExtras(), savedStateHandleFactory: SavedStateHandleFactory? = LocalSavedStateHandleFactory.current, crossinline factory: @DisallowComposableCalls CreationExtras.() -> VM): VM

Returns an existing ViewModel or creates a new one in the given owner (usually, an Android fragment or an Android activity), defaulting to defaultViewModelStoreOwner.

actual inline fun <VM : ViewModel> kmpViewModel(factory: ViewModelFactory<VM>, viewModelStoreOwner: ViewModelStoreOwner, key: String?, extras: CreationExtras, savedStateHandleFactory: SavedStateHandleFactory?): VM
Link copied to clipboard

Remember a ViewModelFactory that will be used to create a ViewModel.

Remember a ViewModelFactory that will be used to create a ViewModel with the given key.

Link copied to clipboard