MavericksViewModelProvider

object MavericksViewModelProvider

Helper ViewModelProvider that has a single method for taking either a Fragment or ComponentActivity instead of two separate ones. The logic for providing the correct scope is inside the method.

Functions

get
Link copied to clipboard
fun <VM : MavericksViewModel<S>, S : MavericksState> get(viewModelClass: Class<out VM>, stateClass: Class<out S>, viewModelContext: ViewModelContext, key: String = viewModelClass.name, forExistingViewModel: Boolean = false, initialStateFactory: MavericksStateFactory<VM, S> = RealMavericksStateFactory()): VM

MvRx specific ViewModelProvider used for creating a BaseMavericksViewModel scoped to either a Fragment or ComponentActivity. If this is in a Fragment, it cannot be called before the Fragment has been added to an Activity or wrapped in a Lazy call.