Skip to content

Conversation

imddc
Copy link
Contributor

@imddc imddc commented Aug 10, 2025

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.
⚠️ Slowing down new functions

Warning: Slowing down new functions

As the VueUse audience continues to grow, we have been inundated with an overwhelming number of feature requests and pull requests. As a result, maintaining the project has become increasingly challenging and has stretched our capacity to its limits. As such, in the near future, we may need to slow down our acceptance of new features and prioritize the stability and quality of existing functions. Please note that new features for VueUse may not be accepted at this time. If you have any new ideas, we suggest that you first incorporate them into your own codebase, iterate on them to suit your needs, and assess their generalizability. If you strongly believe that your ideas are beneficial to the community, you may submit a pull request along with your use cases, and we would be happy to review and discuss them. Thank you for your understanding.


Description

  • JSON Parsing: Automatically parse JSON strings from EventSource into JavaScript objects
  • Custom Transformations: Apply user-defined transformation functions to incoming data
  • Backward Compatibility: All existing functionality remains unchanged, serialization is opt-in

Additional context

This enhancement addresses a common pain point when working with EventSource APIs that send JSON data as strings, requiring manual parsing in every usage. The implementation follows VueUse's existing patterns and maintains full backward compatibility.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Aug 10, 2025
@OrbisK
Copy link
Collaborator

OrbisK commented Aug 10, 2025

Thank you for your PR.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 10, 2025
@imddc imddc changed the title Feat/enhance useEventSource feat(useEventSource): add transformer Aug 11, 2025
Copy link
Collaborator

@OrbisK OrbisK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far. Some small adjustments.

Maybe we should rename it to: serializer like useBase64

@imddc
Copy link
Contributor Author

imddc commented Aug 11, 2025

Looks good so far. Some small adjustments.

Maybe we should rename it to: serializer like useBase64

Thank you!
I have adopted your suggestion, and it looks much better!

@imddc imddc requested a review from OrbisK August 11, 2025 08:14
@OrbisK
Copy link
Collaborator

OrbisK commented Aug 11, 2025

There are no new commits. Maybe you forgot to push 😅

@imddc
Copy link
Contributor Author

imddc commented Aug 12, 2025

There are no new commits. Maybe you forgot to push 😅

I forgot last time. Could you please do the code review again?

@imddc
Copy link
Contributor Author

imddc commented Aug 12, 2025

how about now?

@imddc imddc requested a review from OrbisK August 12, 2025 08:14
Copy link
Collaborator

@OrbisK OrbisK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Thank you!

@OrbisK OrbisK requested review from 43081j and ilyaliao August 12, 2025 08:17
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 12, 2025
@dosubot dosubot bot removed the lgtm This PR has been approved by a maintainer label Aug 13, 2025
@imddc imddc requested a review from OrbisK August 14, 2025 13:34
Copy link

pkg-pr-new bot commented Aug 15, 2025

Open in StackBlitz

@vueuse/components

npm i https://pkg.pr.new/@vueuse/components@4953

@vueuse/core

npm i https://pkg.pr.new/@vueuse/core@4953

@vueuse/electron

npm i https://pkg.pr.new/@vueuse/electron@4953

@vueuse/firebase

npm i https://pkg.pr.new/@vueuse/firebase@4953

@vueuse/integrations

npm i https://pkg.pr.new/@vueuse/integrations@4953

@vueuse/math

npm i https://pkg.pr.new/@vueuse/math@4953

@vueuse/metadata

npm i https://pkg.pr.new/@vueuse/metadata@4953

@vueuse/nuxt

npm i https://pkg.pr.new/@vueuse/nuxt@4953

@vueuse/router

npm i https://pkg.pr.new/@vueuse/router@4953

@vueuse/rxjs

npm i https://pkg.pr.new/@vueuse/rxjs@4953

@vueuse/shared

npm i https://pkg.pr.new/@vueuse/shared@4953

commit: 64629e8

OrbisK
OrbisK previously approved these changes Aug 18, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 18, 2025
@43081j
Copy link
Collaborator

43081j commented Aug 18, 2025

this looks good, but its actually deserialising, right?

it is taking the data from the event and deserialising it. afaik, event source data is always a string and its upto the consumer to deserialise it

if this is the case, we should probably either call it deserializer or we should follow the structure useStorage has (serializer: {read, write}) - but just not use the write part

@OrbisK thoughts?

@OrbisK
Copy link
Collaborator

OrbisK commented Aug 18, 2025

this looks good, but its actually deserialising, right?

Yeah, you're right.

if this is the case, we should probably either call it deserializer or we should follow the structure useStorage has (serializer: {read, write}) - but just not use the write part

I like the idea of having only the read part. If we use this approach, we should update useBase64 to only include the write part (v14).

@43081j
Copy link
Collaborator

43081j commented Aug 18, 2025

👍 that works for me, these 3 functions can share roughly the same serialisation type then, which would be nice

@OrbisK
Copy link
Collaborator

OrbisK commented Aug 18, 2025

@imddc would you mind changing this one more time? 😅

@imddc
Copy link
Contributor Author

imddc commented Aug 18, 2025

@imddc would you mind changing this one more time? 😅

I have modified the code. Please review it again

@OrbisK OrbisK changed the title feat(useEventSource): add transformer feat(useEventSource): add serializer Aug 21, 2025
@OrbisK OrbisK added this pull request to the merge queue Aug 21, 2025
Merged via the queue into vueuse:main with commit 64651a3 Aug 21, 2025
10 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:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants