-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(useStorage): preserve updates when key changes #5059
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
base: main
Are you sure you want to change the base?
Conversation
@vueuse/components
@vueuse/core
@vueuse/electron
@vueuse/firebase
@vueuse/integrations
@vueuse/math
@vueuse/metadata
@vueuse/nuxt
@vueuse/router
@vueuse/rxjs
@vueuse/shared
commit: |
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.
If we don't want users to set flush: pre
, we should restrict it through types
Also, I'm wondering if we should never allow users to pass |
|
oh, I see, because Then I just want to confirm if we can always set it to |
Current Logic Why we cannot always set it to 'sync':
Why we cannot always set it to 'post':
Specific scenario problems: When key and data change simultaneously:
Edge case example:
Conclusion:
Did my answer solve your problem? |
Based on your changes, passing I'm leaning towards refining the type definitions for the |
Thanks for the feedback! You raise valid concerns about the potential impact on existing usage. Looking at this more carefully, I think there are a few ways to approach this:
The core issue we're solving is that when both key and data change in the same tick, we want to preserve the data update rather than having it overwritten by the key change. Would you prefer to explore the type definition approach first, or would you like to see an alternative implementation that doesn't modify the flush behavior? |
Before submitting the PR, please make sure you do the following
(e.g. fixes BUG |
useStorage
| The new value is ignored when changing both the key and value synchronously #4767).Description
storage before same-tick explicit writes land.
update the prior expectation that relied on the old behaviour.
Additional context