Skip to content

Instantly share code, notes, and snippets.

@hansenji
Last active April 1, 2019 03:52
Show Gist options
  • Save hansenji/886412cf69a02f3045159ac67496b859 to your computer and use it in GitHub Desktop.
Save hansenji/886412cf69a02f3045159ac67496b859 to your computer and use it in GitHub Desktop.
class MyViewModel
@ViewModelInject constructor(
Long foo, @Assisted SavedStateHandle savedStateHandle
): ViewModel() {
//...
}
@ViewModelModule
@Module(includes = ViewModelInject_VMModule::class)
abstract class VMModule {}
class MyActivity: Activity {
@Inject
lateinit var viewModelFactoryFactory: SavedStateViewModelFactory.Factory
val viewModel by viewModels<MyViewModel> { viewModelFactoryFactory.create(this, intent.extras) }
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment