Skip to content

Instantly share code, notes, and snippets.

@ceruleanotter
Last active June 20, 2019 18:52
Show Gist options
  • Save ceruleanotter/db4d4d84d9cdb4766da91ba420683dbf to your computer and use it in GitHub Desktop.
Save ceruleanotter/db4d4d84d9cdb4766da91ba420683dbf to your computer and use it in GitHub Desktop.
ViewModel Integrations: Step 2 Saved State Module
// This ktx requires at least androidx.fragment:fragment-ktx:1.1.0 or
// androidx.activity:activity-ktx:1.0.0
val viewModel by viewModels { SavedStateVMFactory(this) }
// Or the non-ktx way...
val viewModel = ViewModelProvider(this, SavedStateVMFactory(this))
.get(MyViewModel::class.java)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment