androidPluto / pluto

Android Pluto is a on-device debugging framework for Android applications, which helps intercept Network calls, capture Crashes & ANRs, manipulate application data on-the-go, and much more.
https://androidpluto.com
Apache License 2.0
673 stars 67 forks source link

Please add support to Proto DataStore #197

Open JosephSanjaya opened 1 year ago

JosephSanjaya commented 1 year ago

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,

srtvprateek commented 1 year ago

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

JosephSanjaya commented 1 year ago

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>)