androidx.hilt.lifecycle.viewmodel.compose

Top-level functions summary

inline VM
@Composable
<VM : ViewModel> hiltViewModel(
    viewModelStoreOwner: ViewModelStoreOwner,
    key: String?
)

Returns an existing HiltViewModel -annotated ViewModel or creates a new one scoped to the current ViewModelStoreOwner.

inline VM
@Composable
<VM : ViewModel, VMF : Any?> hiltViewModel(
    viewModelStoreOwner: ViewModelStoreOwner,
    key: String?,
    noinline creationCallback: (VMF) -> VM
)

Returns an existing HiltViewModel -annotated ViewModel with an @AssistedInject-annotated constructor or creates a new one scoped to the current ViewModelStoreOwner.

Top-level functions

@Composable
inline fun <VM : ViewModel> hiltViewModel(
    viewModelStoreOwner: ViewModelStoreOwner = checkNotNull(LocalViewModelStoreOwner.current) { "No ViewModelStoreOwner was provided via LocalViewModelStoreOwner" },
    key: String? = null
): VM

Returns an existing HiltViewModel -annotated ViewModel or creates a new one scoped to the current ViewModelStoreOwner.

@Composable
inline fun <VM : ViewModel, VMF : Any?> hiltViewModel(
    viewModelStoreOwner: ViewModelStoreOwner = checkNotNull(LocalViewModelStoreOwner.current) { "No ViewModelStoreOwner was provided via LocalViewModelStoreOwner" },
    key: String? = null,
    noinline creationCallback: (VMF) -> VM
): VM

Returns an existing HiltViewModel -annotated ViewModel with an @AssistedInject-annotated constructor or creates a new one scoped to the current ViewModelStoreOwner.