Skip to content

Instantly share code, notes, and snippets.

@mlykotom
Last active February 7, 2021 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlykotom/62f6e363d9d35980a666920fd677018e to your computer and use it in GitHub Desktop.
Save mlykotom/62f6e363d9d35980a666920fd677018e to your computer and use it in GitHub Desktop.
Connecting The Dots :: Assisted Saved State - ViewModel body
class SomeViewModel @AssistedInject constructor(
private val application: Application,
@Assisted private val savedStateHandle: SavedStateHandle
){
// must be inside of the ViewModel class!
@AssistedFactory
interface Factory : AssistedSavedStateViewModelFactory<SomeViewModel> {
override fun create(savedStateHandle: SavedStateHandle): SomeViewModel // may be ommited prior kotlin 1.3.60 or after PR #121 in AssistedInject lib
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment