Created
March 19, 2019 11:26
-
-
Save Nimrodda/3d456b9c836740428047db214484099d 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 @Inject constructor( | |
private val creators: MutableMap<Class<out ViewModel>, Provider<ViewModel>> | |
) : ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
return creators[modelClass]?.get() as? T | |
?: throw IllegalArgumentException("The requested ViewModel isn't bound") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment