HiltViewModelFactory

Added in 1.0.0

public final class HiltViewModelFactory


Summary

Public methods

static final @NonNull ViewModelProvider.Factory
create(
    @NonNull Context context,
    @NonNull ViewModelProvider.Factory delegateFactory
)

Creates a ViewModelProvider.Factory to get HiltViewModel -annotated ViewModel from a ViewModelProvider.Factory.

static final @NonNull ViewModelProvider.Factory
create(
    @NonNull Context context,
    @NonNull NavBackStackEntry navBackStackEntry
)

Creates a ViewModelProvider.Factory to get HiltViewModel -annotated ViewModel from a NavBackStackEntry.

Public methods

create

public static final @NonNull ViewModelProvider.Factory create(
    @NonNull Context context,
    @NonNull ViewModelProvider.Factory delegateFactory
)

Creates a ViewModelProvider.Factory to get HiltViewModel -annotated ViewModel from a ViewModelProvider.Factory.

Parameters
@NonNull Context context

the activity context.

@NonNull ViewModelProvider.Factory delegateFactory

the delegated factory.

Returns
@NonNull ViewModelProvider.Factory

the factory.

Throws
kotlin.IllegalStateException

if the context given is not an activity.

create

public static final @NonNull ViewModelProvider.Factory create(
    @NonNull Context context,
    @NonNull NavBackStackEntry navBackStackEntry
)

Creates a ViewModelProvider.Factory to get HiltViewModel -annotated ViewModel from a NavBackStackEntry.

Parameters
@NonNull Context context

the activity context.

@NonNull NavBackStackEntry navBackStackEntry

the navigation back stack entry.

Returns
@NonNull ViewModelProvider.Factory

the factory.

Throws
kotlin.IllegalStateException

if the context given is not an activity.