This message was deleted.
# android
s
This message was deleted.
e
preferencesDataStore is a function, instead of having a val, create a function that receives the UUID and that function will call preferencesDataStore with the appropriate name
Just be sure to save and return the same dataStore everytime you call the function for the same UUID
I don't have an IDE right now but I imagined something like this
Copy code
typealias MyType = Int

class DataStore {
    private val stores = ConcurrentHashMap<String, DataStore<MyType>>()

    suspend fun get(uuid: String): DataStore<MyType> =
        stores.getOrPut(uuid) {
            preferencesDataStore(
                name = PREFS_NAME,
                produceMigrations = { context -> listOf(SharedPreferencesMigration(context, PREFS_NAME)) }
            )
        }
}