Last active
November 7, 2018 16:20
-
-
Save lewisevans/76062114af186777f8fca5120d5eb086 to your computer and use it in GitHub Desktop.
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 <T : ViewModel> @Inject constructor(private val viewModel: Lazy<T>) : ViewModelProvider.Factory { | |
@Suppress("UNCHECKED_CAST") | |
override fun <T : ViewModel?> create(modelClass: Class<T>): T = viewModel.get() as T | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment