Created
November 29, 2018 22:42
-
-
Save tfcporciuncula/3b7da90bd42bd61154ff6c536cc5a873 to your computer and use it in GitHub Desktop.
ViewModelFactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewModelFactory<VM : ViewModel> @Inject constructor( | |
private val viewModel: Lazy<VM> | |
) : ViewModelProvider.Factory { | |
@Suppress("UNCHECKED_CAST") | |
override fun <T : ViewModel> create(modelClass: Class<T>) = viewModel.get() as T | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment