InitializerViewModelFactoryBuilder


@ViewModelFactoryDsl
public final class InitializerViewModelFactoryBuilder


DSL for constructing a new ViewModelProvider.Factory

Summary

Public constructors

Public methods

final void
<T extends ViewModel> addInitializer(
    @NonNull KClass<@NonNull T> clazz,
    @ExtensionFunctionType @NonNull Function1<@NonNull CreationExtras, @NonNull T> initializer
)

Associates the specified initializer with the given ViewModel class.

final @NonNull ViewModelProvider.Factory

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

Extension functions

final void

Add an initializer to the InitializerViewModelFactoryBuilder

Public constructors

InitializerViewModelFactoryBuilder

Added in 2.5.0
public InitializerViewModelFactoryBuilder()

Public methods

addInitializer

Added in 2.5.0
public final void <T extends ViewModel> addInitializer(
    @NonNull KClass<@NonNull T> clazz,
    @ExtensionFunctionType @NonNull Function1<@NonNull CreationExtras, @NonNull T> initializer
)

Associates the specified initializer with the given ViewModel class.

Parameters
@NonNull KClass<@NonNull T> clazz

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

@ExtensionFunctionType @NonNull Function1<@NonNull CreationExtras, @NonNull T> initializer

factory lambda to be associated with the specified ViewModel class.

build

Added in 2.5.0
public final @NonNull ViewModelProvider.Factory build()

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

Extension functions

InitializerViewModelFactoryKt.initializer

public final void <VM extends ViewModel> InitializerViewModelFactoryKt.initializer(
    @NonNull InitializerViewModelFactoryBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull CreationExtras, @NonNull VM> initializer
)

Add an initializer to the InitializerViewModelFactoryBuilder