InitializerViewModelFactoryBuilder



DSL for constructing a new ViewModelProvider.Factory

Summary

Public constructors

Cmn

Public functions

Unit
<T : ViewModel> addInitializer(clazz: KClass<T>, initializer: CreationExtras.() -> T)

Associates the specified initializer with the given ViewModel class.

Cmn
ViewModelProvider.Factory

Returns an instance of ViewModelProvider.Factory created from the initializers set on this builder.

Cmn

Extension functions

inline Unit
<VM : ViewModel> InitializerViewModelFactoryBuilder.initializer(
    noinline initializer: CreationExtras.() -> VM
)

Add an initializer to the InitializerViewModelFactoryBuilder

Cmn

Public constructors

InitializerViewModelFactoryBuilder

InitializerViewModelFactoryBuilder()

Public functions

addInitializer

fun <T : ViewModel> addInitializer(clazz: KClass<T>, initializer: CreationExtras.() -> T): Unit

Associates the specified initializer with the given ViewModel class.

Parameters
clazz: KClass<T>

ViewModel class with which the specified initializer is to be associated.

initializer: CreationExtras.() -> T

factory lambda to be associated with the specified ViewModel class.

build

fun build(): ViewModelProvider.Factory

Returns an instance of ViewModelProvider.Factory created from the initializers set on this builder.

Extension functions

inline fun <VM : ViewModel> InitializerViewModelFactoryBuilder.initializer(
    noinline initializer: CreationExtras.() -> VM
): Unit

Add an initializer to the InitializerViewModelFactoryBuilder