Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add support to Proto DataStore #197

Open
JosephSanjaya opened this issue Dec 15, 2022 · 2 comments
Open

Please add support to Proto DataStore #197

JosephSanjaya opened this issue Dec 15, 2022 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@JosephSanjaya
Copy link

Is your feature request related to a problem? Please describe.
Currently im using proto datastore to support encryption, but i can't seems attach watcher because it need to use Preferences generic class.

Describe the solution you'd like
Please add support Proto DataStore with custom serializer,

@JosephSanjaya JosephSanjaya added the enhancement New feature or request label Dec 15, 2022
@srtvprateek
Copy link
Member

hey @JosephSanjaya,
can you elaborate your issue in detail?

@JosephSanjaya
Copy link
Author

I'm using Proto DataStore with custom serializer, for example

DataStore<UserPrefData>

but currently PlutoDatastoreWatcher, is just supported DataStore with Preferences (DataStore Pref)

DataStore<Preferences>

you can see in com.pluto.plugins.datastore.pref.PlutoDatastoreWatcher it only support DataStore Pref.

object PlutoDatastoreWatcher {

    internal val sources = MutableStateFlow<Set<PreferenceHolder>>(emptySet())

    fun watch(name: String, store: DataStore<Preferences>) {
        sources.update { oldSet ->
            mutableSetOf<PreferenceHolder>().apply {
                addAll(oldSet)
                add(PreferenceHolder(name, store))
            }
        }
    }

    fun remove(name: String) {
        sources.update { oldSet ->
            mutableSetOf<PreferenceHolder>().apply {
                oldSet.forEach {
                    if (it.name != name) add(it)
                }
            }
        }
    }
}

internal data class PreferenceHolder(val name: String, val preferences: DataStore<Preferences>)

@srtvprateek srtvprateek added the help wanted Extra attention is needed label Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants