-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visited frequently #5
Comments
Subtasks
|
TakeawaysWeb storage size limitsWeb storage size per origin is roughly 10MB. But it can be configured to less or it does not have to be available at all. JavaScript date object takes 26 bytes. Spot ID 24 bytes. Object containing both ~70 bytes. (How to calculate it) Local storage with 10 MB quota can hold up to ~ 143.000 id-date pairs. Even with 50 spot visits daily it will take 8 years to fill the available storage. If the format won't be id + date pair for each visit, but id + array of dates, it will take even less space. Conclusion: There is no need to limit or clear visits from storage. User will change browser, delete cache or I will move the visits to database before anyone hits the limit. Redux and localStorage
Even though web storage size limit won't be a problem, object containing all visits will be huge and JSON.stringify is performance-heavy. Hence saving visits to local storage should happen only when new visit is recorded. Doing it in middleware would mean it happens before the store is changed. Doing it in subscribe would mean we cannot distinguish visits store tree updated from other updates.
I can see two options:
Let's use redux-persist. MiscAccessing local storage should be wrapped in try-catch block to solve gracefully all possible problems like missing or full local storage. Be careful that local storage shape might be outdated. This is why redux-persist provides migrations config. |
The user can see names of the frequently visited spots on the homepage to quickly navigate to them.
The text was updated successfully, but these errors were encountered: