vector / com.haroldadmin.vector / androidx.fragment.app.Fragment / activityViewModel
activityViewModel¶
inline fun <reified VM :
VectorViewModel
<
S
>, reified S :
VectorState
>
Fragment
.activityViewModel(stateStoreContext:
CoroutineContext
= Dispatchers.Default + Job()):
vectorLazy
<
VM
>
Lazy delegate for creating an activity scoped VectorViewModel from a Fragment. Creates and returns the requested VectorViewModel automatically using reflection. The returned ViewModel is scoped to this Fragment's parent activity.
Parameters¶
VM
- The type of the VectorViewModel being requested
S
- The type of State class bound to the requested ViewModel
stateStoreContext
- The CoroutineContext to be used in the ViewModel's state storeinline fun <reified VM :
VectorViewModel
<
S
>, reified S :
VectorState
>
Fragment
.activityViewModel(noinline viewModelCreator: (initialState:
S
, handle:
SavedStateHandle
) ->
VM
):
vectorLazy
<
VM
>
Lazy delegate for creating a parent activity scoped VectorViewModel from a Fragment using the given producer lambda
Creates and returns the requested VectorViewModel automatically using reflection. The returned ViewModel is scoped to this Fragment's parent activity.
Parameters¶
VM
- The type of the VectorViewModel being requested
S
- The type of State class bound to the requested ViewModel
viewModelCreator
- The lambda which creates and returns the requested ViewModel