apsun / RemotePreferences

A drop-in solution for inter-app access to SharedPreferences.
MIT License
138 stars 32 forks source link

Added the overridable method getSharedPreferences() #23

Closed Yubyf closed 2 years ago

Yubyf commented 2 years ago

To provide a custom implementation interface for SharedPreferences(like DataStore).

apsun commented 2 years ago

Implementation looks good, although I'm unclear how you will actually use this. DataStore doesn't seem to implement the SharedPreferences interface as far as I can tell (unless you plan to write some kind of DataStore -> SharedPreferences adapter?)

Yubyf commented 2 years ago

Implementation looks good, although I'm unclear how you will actually use this. DataStore doesn't seem to implement the SharedPreferences interface as far as I can tell (unless you plan to write some kind of DataStore -> SharedPreferences adapter?)

Yes, some time ago when I migrated SharedPreferences to DataStore, I found that I still needed to adapt the interface of SharedPreferences in some places (like RemotePreferences).

Therefore, I wrote a simple implementation here.

Since this library is not elegant enough and needs to use Kotlin Coroutine, I did not commit it here.

apsun commented 2 years ago

I see, makes sense! This might also be useful if someone ever wants to chain multiple RemotePreference instances together, I guess. I just have some minor nits regarding naming and docs, otherwise this LGTM.