Package-level declarations

Types

Link copied to clipboard
class DefaultViewModelProviderFactory : ViewModelProvider.Factory
Link copied to clipboard
object EmptyCreateKey : CreationExtras.Key<EmptyConstructor>
Link copied to clipboard
actual class LifecycleOwnerDelegate : LifecycleOwner, ViewModelStoreOwner, SavedStateRegistryOwner, HasDefaultViewModelProviderFactory
expect class LifecycleOwnerDelegate : LifecycleOwner, ViewModelStoreOwner, SavedStateRegistryOwner, HasDefaultViewModelProviderFactory
actual class LifecycleOwnerDelegate : LifecycleOwner, ViewModelStoreOwner, SavedStateRegistryOwner, HasDefaultViewModelProviderFactory
actual class LifecycleOwnerDelegate : LifecycleOwner, ViewModelStoreOwner, SavedStateRegistryOwner, HasDefaultViewModelProviderFactory
actual class LifecycleOwnerDelegate : LifecycleOwner, ViewModelStoreOwner, SavedStateRegistryOwner, HasDefaultViewModelProviderFactory
Link copied to clipboard
object SavedStateHandleCreateKey : CreationExtras.Key<SSHConstructor>

Functions

Link copied to clipboard
fun Lifecycle.addEventObserver(body: (source: LifecycleOwner, event: Lifecycle.Event) -> Unit)

添加事件监听

Link copied to clipboard
expect fun createLifecycleOwnerDelegate(viewModelStoreProvider: MRouterViewModelStoreProvider?, hostLifecycleState: Lifecycle.State = Lifecycle.State.CREATED, immutableArgs: Bundle?): LifecycleOwnerDelegate
actual fun createLifecycleOwnerDelegate(viewModelStoreProvider: MRouterViewModelStoreProvider?, hostLifecycleState: Lifecycle.State, immutableArgs: Bundle?): LifecycleOwnerDelegate
actual fun createLifecycleOwnerDelegate(viewModelStoreProvider: MRouterViewModelStoreProvider?, hostLifecycleState: Lifecycle.State, immutableArgs: Bundle?): LifecycleOwnerDelegate
actual fun createLifecycleOwnerDelegate(viewModelStoreProvider: MRouterViewModelStoreProvider?, hostLifecycleState: Lifecycle.State, immutableArgs: Bundle?): LifecycleOwnerDelegate
Link copied to clipboard
@Composable
fun <VM : ViewModel> ViewModelStoreOwner.createVM(modelClass: KClass<VM>, key: String?, extras: CreationExtras): VM

用于构造简单的ViewModel的工厂

Link copied to clipboard
inline fun <T : Any> getKClassForGenericType(): KClass<T>
Link copied to clipboard
@Composable
actual fun LifecycleOwnerDelegate.LocalOwnersProvider(saveableStateHolder: SaveableStateHolder, pageScope: PageScope, content: () -> Unit)
@Composable
expect fun LifecycleOwnerDelegate.LocalOwnersProvider(saveableStateHolder: SaveableStateHolder, pageScope: PageScope, content: @Composable () -> Unit)
@Composable
actual fun LifecycleOwnerDelegate.LocalOwnersProvider(saveableStateHolder: SaveableStateHolder, pageScope: PageScope, content: () -> Unit)
@Composable
actual fun LifecycleOwnerDelegate.LocalOwnersProvider(saveableStateHolder: SaveableStateHolder, pageScope: PageScope, content: () -> Unit)
@Composable
actual fun LifecycleOwnerDelegate.LocalOwnersProvider(saveableStateHolder: SaveableStateHolder, pageScope: PageScope, content: () -> Unit)
Link copied to clipboard
@Composable
inline fun <VM : ViewModel> viewModel(noinline block: () -> VM, key: String? = null): VM

用于构造具有空构造函数的ViewModel,如果需要更加强大的构造方式可以使用其他第三方库,比如koin

@Composable
inline fun <VM : ViewModel> viewModel(noinline block: (SavedStateHandle) -> VM, key: String? = null): VM

用于构造有且只有SavedStateHandle作为参数的构造函数的ViewModel

Link copied to clipboard
@Composable
fun <T : ViewModel> viewModelImpl(modelClass: KClass<T>, emptyBlock: () -> T? = null, block: (SavedStateHandle) -> T? = null, key: String? = null): T

实际构造ViewModel的方法