chain-desktop-wallet
chain-desktop-wallet copied to clipboard
Proposal: refine the current state flow
There are many "states" not updated in real-time, mainly because of the current state flow:
- (1). Fetch data from API and store them in the database(NeDB)
- (2). Components(UI) retrieve data from the database and update them in recoil atoms
- (3). Components(UI) read the newly updated atoms and update UI
For steps 1, 2, they are imperative, but for step 3, it's reactive, once the states flush into the atoms, we are all set, the UI will be updated in real-time.
But at this point, many actions we take(eg. network request, fetch data from DB) do not produce side-effects or lack some mechanism to produce(or we forgot to), currently, we have to update it by hand.
Also considering the fact that the whole app is not usable until the home refresh action is done, some data caching in NeDB is not that necessary, we can fetch them and store them directly into the atoms and we can get rid of some unnecessary behaviors such as "clean cache before fetching assets", "state only get updated when clicking the refresh button(because only there we do step 2)
So I suggest making some changes to the current state flow and reducing the usage of NeDB, making sure that every time we emit an action, there is a state change side-effect, let the app be more "reactive".
More details will be listed in future PR.
Related Issues: