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
feat: add in-memory storage as a fallback for disabled LocalStorage #533
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey! thanks for your PR man! Left some comments, lmk :)
Ready to be checked @mrousavy We have a single warning and my app is up and running 🪄 |
@mrousavy is there anything I can do with failed job? |
Hey - for some reason the linter failed. I'll fix that, your PR looks good! I'm thinking if we should also use the in-memory Map fallback for when JSI is unavailable, e.g. when running in a Chrome debugger? |
If it causes a crash then yes, it's still better to have limited experience, yet let the user debug the app. |
while this PR is great and works as expected inside the browser, it does flood and spam the Next.js server console now. This is throwing an incredible amount of console.log's now while navigating for us. |
I think the console.log should only be printed if |
Hello @mrousavy ✋
I am submitting this pull request to propose the addition of a new feature
webFallbackStorage
. The purpose of this enhancement is to provide a more resilient storage option for web environments, particularly when users disablelocalStorage
in their browsers.The
webFallbackStorage
is designed as an optional property that conforms to theStorage
type. It allows the application to handle disabledlocalStorage
situations gracefully by offering eg. in-memory storage as an alternative. This ensures smooth functioning of the application despite any user-imposed limitations.Right now,
react-native-mmkv
throws an error and there is no way to run themonorepo
with disabledlocalStorage
.Here's a brief overview of the changes introduced with this feature:
webFallbackStorage
property has been added as an optional attribute, maintaining backward compatibility with existing implementations.localStorage
, the application will seamlessly transition to usingwebFallbackStorage
, ensuring no disruption in the user experience.webFallbackStorage
property is not provided, the default behavior remains unchanged, and an error will be thrown in caselocalStorage
is disabled.I believe this enhancement will significantly improve the robustness and flexibility of the
react-native-mmkv
library.Later we can add default
in-memory
storage to the lib.Please feel free to reach out to me with any questions or suggestions.