Skip to content

Comments

feat: add new function useWebWorkerIntervalFn#5043

Open
bprag wants to merge 27 commits intovueuse:mainfrom
bprag:fix/useWebSocket
Open

feat: add new function useWebWorkerIntervalFn#5043
bprag wants to merge 27 commits intovueuse:mainfrom
bprag:fix/useWebSocket

Conversation

@bprag
Copy link

@bprag bprag commented Sep 16, 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

fix #4671

Additional context

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 16, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 16, 2025

Open in StackBlitz

@vueuse/components

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

@vueuse/core

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

@vueuse/electron

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

@vueuse/firebase

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

@vueuse/integrations

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

@vueuse/math

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

@vueuse/metadata

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

@vueuse/nuxt

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

@vueuse/router

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

@vueuse/rxjs

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

@vueuse/shared

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

commit: 52ff2fa

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. size:L This PR changes 100-499 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. size:XS This PR changes 0-9 lines, ignoring generated files. labels Sep 19, 2025
@bprag bprag requested a review from 9romise September 24, 2025 02:00
@codecov
Copy link

codecov bot commented Sep 24, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Sep 24, 2025
@bprag bprag requested a review from 9romise September 25, 2025 08:46
Copy link
Member

@9romise 9romise left a comment

Choose a reason for hiding this comment

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

It might be better to split this PR into smaller parts:

  1. Add useWebWorkerInternal
  2. Add custom scheduler support for useWebSocket

Let’s focus on completing step 1 here first.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 26, 2025
@bprag bprag requested a review from 9romise September 26, 2025 01:45
@bprag bprag closed this Sep 28, 2025
@bprag bprag reopened this Sep 28, 2025
Copy link
Author

@bprag bprag left a comment

Choose a reason for hiding this comment

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

The first step has been completed

@9romise 9romise changed the title fix(useWebSocket): add worker type support in heartbeat feat: add new function useWebWorkerIntervalFn Sep 29, 2025
Copy link
Member

@9romise 9romise left a comment

Choose a reason for hiding this comment

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

It seems to share a lot of overlapping code with useWebWorkerFn. Would there be any challenges in building this on top of it?

@bprag
Copy link
Author

bprag commented Nov 21, 2025

It seems to share a lot of overlapping code with useWebWorkerFn. Would there be any challenges in building this on top of it?

useWebWorkerFn is fundamentally a “single-run worker”, designed for one-off tasks.
While we could technically build a timer on top of it, each tick would require creating a new Worker and recursively scheduling it on the main thread, which doesn’t align with its intended design.
A dedicated useWebWorkerIntervalFn for timers would be cleaner and more efficient.

@bprag bprag requested a review from 9romise December 4, 2025 08:35
Copy link
Member

@9romise 9romise left a comment

Choose a reason for hiding this comment

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

What is the reason for the renaming?

@bprag bprag requested a review from 9romise December 5, 2025 06:09
@bprag bprag requested a review from 9romise December 8, 2025 07:37
@bprag
Copy link
Author

bprag commented Dec 30, 2025

Hi @9romise 👋
I’ve addressed the requested changes based on the previous review, but I’m not sure if there are still any outstanding issues.

Could you please let me know if there’s anything else that needs to be updated, or if I missed any specific points?
Thanks a lot!

@9romise
Copy link
Member

9romise commented Jan 4, 2026

I don’t think this PR is quite ready yet, as there are still some minor issues — including inconsistent method naming and types (both useWebWorkerInterval and useWebWorkerIntervalFn appear, for example). Perhaps you could spend a little time cleaning up the PR.

I’m also unsure whether the current setTimeout‑based implementation is appropriate, and I’d like to hear what others think as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new function size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG | useWebSocket | heartbeat inaccurate interval timing

3 participants