refactor(neon_framework): use a separate persistence layer backing th… #1602
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…e storages
The general idea is to decouple the storage layer, the app is talking to, from the layer actually persisting the data.
A
Persistence
is just a basic CRUD like (maybe asynchronous) interface for the storage layers to use. Other implementations like theCachedPersistence
cache the data in memory (HashMap) so reads can be synchronous while writes are asynchronous in the background.In turn we can build a complete
SharedPreferences
implementation on to of the cached persistence. Currently theSharedPreferencesPersistence
is just aCachedPeristence
warper around the shared preferences (with some key handling magic to allow the current data to seamlessly be used without any migration).I understand that the current default implementation of our storages (
SettingsStore
andSingleValueStore
) are already wrappers themselves but with the up cumming migration to a SQLite persistence we will no longer have the double wrappers. This may seem like a lot of unnecessary boilerplate interfaces but as shown in #1585 it will allow us to make changes with minimal effort.We can later consider changing some of these patterns but it was the easiest way to tackle it in a reviewable small patch-set.