-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
♻️ ability to specify optional provider for sessionStorage #14
Conversation
7402a2a
to
15b3ffb
Compare
I became painfully aware that sessionStorage does not emit an I believe using |
Hi @Rendez, Thank you very much for your contribution. I hope you don't mind a few questions:
|
Ok, I didn't go through that issue initiall, but now I have... I still need sessionStorage, but it suffers from the same shortcoming as explained in: #9 (comment). That's why we'll be using localStorage instead, because sessionStorage's event doesn't behave the same way (only works within iframes in the same tab). The issue with localStorage in my opinion is that is too persistent, it sticks around forever and it's hard to "mend" it once you've shipped it to production. I have implemented our feature the next way: {
[id]: ExpirationTimestamp,
[id2]: ExpirationTimestamp,
} If a flag is false, it's removed from the map, if it's added it's added with a timestamp value (+2 days). This is a lot of bookeeping just because we are forced to use localStorage. Which is fine. However, not everyone needs tab-synchonization, or don't care about that feature as much, because they simply want to keep state upon (refreshes of the page). sessionStorage is a non-so-serious approach, offers some benefits and allows you to be more lax about keeping your Storage keys around, since you know they'll be wiped-out eventually when the user closes the browser. I am with you however, in trying to find meaningful use cases that justify adding sessionStorage to this package. I understand it quite well. |
I am currently working on some Big Sur issues with our app and am busy. I will answer you at the first opportunity. There isn't a chance I will forget. |
Thanks for the detailed explanation. I have another idea for solving the support of
Making another module which is very close to this one solves all of the above issues. What do you think? Do I make sense? |
I totally like your reasoning. The only thing I would keep in mind is to make sure that tests aren't duplicated. Maybe that would require this to become a monorepo so we can write shared tests? |
What problem do you see with duplicate tests? |
I am closing this because:
I am sorry that your contribution didn't get merged. I am sad when this happens. |
@astoilkov in retrospective, I learnt a lot and there is nothing to be sorry about, you were very open about my idea :) |
❤️ |
I need this library to work with sessionStorage as well and I find the implementation really neat. As you'll notice, I haven't changed the exported functions's name to reflect the changes yet, as I would wait for your feedback first, but one option is to export 4 functions:
The breaking API alternative is to provide 2 functions instead, like now, but rename them to these (or similar):
Also, though test coverage remains at 100%, if you'd like to avoid the duplication created, I could improve on that too.
Looking forward to your feedback.