hello! I try create 2 datastore in kmp with koin, ...
# koin
a
hello! I try create 2 datastore in kmp with koin, this code not working, app crash with error: ava.lang.ClassCastException: ProfileDto cannot be cast to SettingsDto
Copy code
actual val dataStoreModule: Module = module {
    single {
        createProfileDataStore {
            createAndroidFilePath(get(), "profile.json")
        }
    }
    single {
        createSettingsDataStore {
            createAndroidFilePath(get(), "settings.json")
        }
    }
}
But if i add named, all works good, it good practice, or u have better way for provide 2 different datastore in kmp? In hilt(android native) works good without named param
Copy code
enum class DataStoreType {
    Profile,
    Settings
}

actual val datastoreModule: Module = module {
    single<DataStore<ProfileDto>>(
        named(DataStoreTypes.Profile)
    ) {
        createProfileDataStore {
            createAndroidFilePath(get(), "profile.json")
        }
    }
    single<DataStore<SettingsDto>>(
        named(DataStoreTypes.Settings)
    ) {
        createTokensDataStore {
            createAndroidFilePath(get(), "settings.json")
        }
    }
}