Android, Jetpack, Jetpack Datastore.
(modelClass.isAssignableFrom(MyViewModel::class.java)) { @Suppress("UNCHECKED_CAST") return MyViewModel(appModule.userPreferencesStore) as T } throw IllegalArgumentException("Unknown ViewModel class") } } Explanation: We create a UserPreferencesModule using Koin (or a similar library) to provide