Skip to content

feat(useIDBKeyval): add options.serializer #4781

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

Merged
merged 7 commits into from
Jul 9, 2025

Conversation

matthewjumpsoffbuildings
Copy link
Contributor

@matthewjumpsoffbuildings matthewjumpsoffbuildings commented May 28, 2025

Description

Attempt to add serializer option to useIDBKeyval to bring it more in line with useStorage as per https://vueuse.org/core/useStorage/#custom-serialization

Closes #4780

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. enhancement New feature or request labels May 28, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels May 28, 2025
@ilyaliao
Copy link
Member

ilyaliao commented Jun 4, 2025

Thank you for your PR. Can you add some tests for this feature to prevent future regressions?

@acrobid
Copy link

acrobid commented Jul 9, 2025

I've encountered this breaking change in production and created minimal reproductions that demonstrate the issue:

Before v10.9.0 (working): https://stackblitz.com/edit/vitejs-vite-cdqkbqje?file=package.json
Current version (broken): https://stackblitz.com/edit/vitejs-vite-hzsdf8sq?file=package.json

This change has been blocking our upgrade from @vueuse/integrations v10.7.2. Since it was released as a minor version update, we didn't anticipate breaking changes.

I came here to propose a serialization option and am glad to see it's already been suggested! The approach in this PR looks great and would solve our use case perfectly.

Is there anything I can do to help move this forward? I'd be happy to:

Test the PR in our production environment
Add test cases for edge cases we've encountered
Help with documentation

Thank you for working on this!

@OrbisK
Copy link
Collaborator

OrbisK commented Jul 9, 2025

@matthewjumpsoffbuildings lets get this over the line! Would you be willing to add the suggestions?

@OrbisK
Copy link
Collaborator

OrbisK commented Jul 9, 2025

@acrobid You can use pnpm patch command to test whether this approach works for you. I think we might merge this soon. But I think we will not backport this to older major versions.

@matthewjumpsoffbuildings
Copy link
Contributor Author

@OrbisK @acrobid I pushed some commits attempting to apply the suggestions, default serializer, better typing etc

I don't have time to write tests right now, if someone else can handle that that would be good

Adds some tests and also changes the serializer type to deal with
`unknown` rather than `any`.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 9, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 9, 2025
@43081j 43081j added this pull request to the merge queue Jul 9, 2025
@OrbisK OrbisK removed this pull request from the merge queue due to a manual request Jul 9, 2025
@OrbisK OrbisK changed the title Initial attempt of serializer for useIDBKeyval feat(useIDBKeyval): add options.serializer Jul 9, 2025
@OrbisK OrbisK added this pull request to the merge queue Jul 9, 2025
Merged via the queue into vueuse:main with commit bb83178 Jul 9, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useIDBKeyval | custom serialization as per useStorage
5 participants