Currently our data model involves fetching all core app data from the node upon load, store it in memory (observables) and cache it in local storage. It would be better to have one source of truth in a frontend indexed db and make it reactive to update the UI in real time.
For some upcoming accounting features, we need to add the ability to add metadata to transactions to categorise them for accounting purposes, so it is probably better to refactor our storage API before adding that feature.
We can use Dexie.js for a reactive wrapper around the IndexedDB API. In future we can also add a data export and import feature for syncing across devices and backups.
We change the data fetching model so that on first load of the app, we can show a "Syncing with your node" splash screen while we fetch all of the data the app needs as much as the provided rune will allow. We can then transform the data and store in the DB which becomes the source of truth for the UI. Any updates to state will be written to the DB and then reactively updated in the UI.
On subsequent loads, we can then lookup in the db the latest data we have and then make calls to the node to get the latest data selectively by either using the sql RPC method or the filtering options on certain RPC methods.
This will also allow for the app to work readonly offline as well.
Currently our data model involves fetching all core app data from the node upon load, store it in memory (observables) and cache it in local storage. It would be better to have one source of truth in a frontend indexed db and make it reactive to update the UI in real time. For some upcoming accounting features, we need to add the ability to add metadata to transactions to categorise them for accounting purposes, so it is probably better to refactor our storage API before adding that feature.
We can use Dexie.js for a reactive wrapper around the IndexedDB API. In future we can also add a data export and import feature for syncing across devices and backups.
We change the data fetching model so that on first load of the app, we can show a "Syncing with your node" splash screen while we fetch all of the data the app needs as much as the provided rune will allow. We can then transform the data and store in the DB which becomes the source of truth for the UI. Any updates to state will be written to the DB and then reactively updated in the UI. On subsequent loads, we can then lookup in the db the latest data we have and then make calls to the node to get the latest data selectively by either using the
sql
RPC method or the filtering options on certain RPC methods.This will also allow for the app to work readonly offline as well.