ViewModelContext

sealed class ViewModelContext

Creation context for the ViewModel. Includes the ViewModel store owner (either an activity or fragment), and fragment arguments set via Mavericks.KEY_ARG.

For activity scoped ViewModels see ActivityViewModelContext. For fragment scoped ViewModels see FragmentViewModelContext.

Never store a reference to this context, or the activity/fragment.

Functions

activity
Link copied to clipboard
fun <A : ComponentActivity> activity(): A

Convenience method to type activity.

app
Link copied to clipboard
fun <A : Application> app(): A

Convenience method to access a typed Application.

args
Link copied to clipboard
fun <A> args(): A

Convenience method to type args.

Properties

activity
Link copied to clipboard
abstract val activity: ComponentActivity

The activity which is using the ViewModel.

args
Link copied to clipboard
abstract val args: Any?

Fragment arguments set via Mavericks.KEY_ARG.

Inheritors

ActivityViewModelContext
Link copied to clipboard
FragmentViewModelContext
Link copied to clipboard