Package-level declarations

Types

Link copied to clipboard

Functions

Link copied to clipboard
inline fun <VM : ViewModel> Fragment.injectedActivityViewModel(noinline extrasProducer: () -> CreationExtras? = null): Lazy<VM>
Link copied to clipboard
inline fun <VM : ViewModel> injectedViewModel(viewModelStoreOwner: ViewModelStoreOwner = checkNotNull(LocalViewModelStoreOwner.current) { "No ViewModelStoreOwner was provided via LocalViewModelStoreOwner" }, key: String? = null, extras: CreationExtras = if (viewModelStoreOwner is HasDefaultViewModelProviderFactory) { viewModelStoreOwner.defaultViewModelCreationExtras } else { CreationExtras.Empty }): VM

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

fun <VM : ViewModel> injectedViewModel(modelClass: Class<VM>, viewModelStoreOwner: ViewModelStoreOwner = checkNotNull(LocalViewModelStoreOwner.current) { "No ViewModelStoreOwner was provided via LocalViewModelStoreOwner" }, key: String? = null, extras: CreationExtras = if (viewModelStoreOwner is HasDefaultViewModelProviderFactory) { viewModelStoreOwner.defaultViewModelCreationExtras } else { CreationExtras.Empty }): VM

Returns an existing ViewModel or creates a new one in the scope (usually, a fragment or an activity)

Link copied to clipboard
inline fun <VM : ViewModel> ComponentActivity.injectedViewModel(noinline extrasProducer: () -> CreationExtras = { defaultViewModelCreationExtras }): Lazy<VM>

ComponentActivity.viewModels that uses application's ViewModelProvider.Factory

inline fun <VM : ViewModel> Fragment.injectedViewModel(noinline ownerProducer: () -> ViewModelStoreOwner = { this }, noinline extrasProducer: () -> CreationExtras? = null): Lazy<VM>