Hello everyone, I am using Koin to inject shared p...
# koin
p
Hello everyone, I am using Koin to inject shared preferences instance. I have one instance which works fine, but now i would like to add the second. How can I distinguish which one should be used? Here is my implementation:
Copy code
val preferencesModule = module {
    single { provideSettingsPreferences(androidApplication()) }
}

private const val PREFERENCES_FILE_KEY = "com.myapp.shared_preferences"

private fun provideSettingsPreferences(app: Application): SharedPreferences =
        app.getSharedPreferences(PREFERENCES_FILE_KEY, Context.MODE_PRIVATE)
p
p
awesome. It is exactly what I need 🙂 , small addition. What about named function in constructor?
Copy code
class MyAppViewModel(private val sharedPreferences: SharedPreferences) : BaseViewModel() {}
@arnaud.giuliani if you could take a look 🙂 ?
a
you can use a qualifier with your get:
get(named("your_stuff"))
🙇‍♂️ 1
141 Views