Created
September 30, 2020 12:49
-
-
Save robotsquidward/1113b64a7c822200ec27f747ed793a33 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fun createWithFactory( | |
create: () -> ViewModel | |
): ViewModelProvider.Factory { | |
return object : ViewModelProvider.Factory { | |
override fun <T : ViewModel?> create(modelClass: Class<T>): T { | |
@Suppress("UNCHECKED_CAST")// Casting T as ViewModel | |
return create.invoke() as T | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment