ViewModelStoreOwnerFactory
public final class ViewModelStoreOwnerFactory
Summary
Public methods
create
public static final @NonNull ViewModelStoreOwner create(
@NonNull ViewModelStore viewModelStore,
@NonNull SavedState defaultArgs,
@NonNull CreationExtras defaultCreationExtras,
@NonNull ViewModelProvider.Factory defaultFactory
)
Creates a ViewModelStoreOwner by composing a store, factory, and creation extras.
create
public static final @NonNull ViewModelStoreOwner create(
@NonNull ViewModelStore viewModelStore,
@NonNull SavedStateRegistryOwner savedStateRegistryOwner,
@NonNull SavedState defaultArgs,
@NonNull CreationExtras defaultCreationExtras,
@NonNull ViewModelProvider.Factory defaultFactory
)
Creates a ViewModelStoreOwner that also acts as a SavedStateRegistryOwner, composing a store, state registry, lifecycle, factory, and creation extras.
While the simpler ViewModelStoreOwner factory handles standard ViewModels, this overload provides the necessary infrastructure for ViewModels that rely on SavedStateHandle. By bundling the SavedStateRegistryOwner with the store, it creates a fully equipped scope capable of properly wiring up state-saving mechanisms for its ViewModels.
create
public static final @NonNull ViewModelStoreOwner create(
@NonNull ViewModelStore viewModelStore,
@NonNull SavedStateRegistry savedStateRegistry,
@NonNull Lifecycle lifecycle,
@NonNull SavedState defaultArgs,
@NonNull CreationExtras defaultCreationExtras,
@NonNull ViewModelProvider.Factory defaultFactory
)
Creates a ViewModelStoreOwner that also acts as a SavedStateRegistryOwner, composing a store, state registry, lifecycle, factory, and creation extras.
While the simpler ViewModelStoreOwner factory handles standard ViewModels, this overload provides the necessary infrastructure for ViewModels that rely on SavedStateHandle. By bundling the SavedStateRegistry and Lifecycle with the store, it creates a fully equipped scope capable of properly wiring up state-saving mechanisms for its ViewModels.
