Skip to content
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

fix: throttle event listener function #705

Merged
merged 4 commits into from
Jul 23, 2023

Conversation

wxharry
Copy link
Collaborator

@wxharry wxharry commented Jul 17, 2023

Brief Information

This pull request is in the type of (more info about types):

  • build
  • ci
  • docs
  • feat
  • fix
  • perf
  • refactor
  • test

Related issues (all available keywords):

Details

  1. add a debounce function
  2. debouce the function added to the turbo:render event

Checklist

Others

@menbotics menbotics bot added the kind/bug Category issues or prs related to bug. label Jul 17, 2023
src/feature-manager.ts Outdated Show resolved Hide resolved
@andyhuang18
Copy link
Collaborator

I can't view the chart of Starred.

2023-07-17.12-44-01.mp4

@l1tok
Copy link
Collaborator

l1tok commented Jul 17, 2023

There are no bugs on mine. I can view the chart of Starred.
xx
1

@andyhuang18
Copy link
Collaborator

I can't view the chart of Starred.

2023-07-17.12-44-01.mp4

I made a mistake, so far everything is OK!

@tyn1998
Copy link
Member

tyn1998 commented Jul 18, 2023

Hey @wxharry, thanks for your solution!

This solution works, however, it delays all loadings of features after tab switches. If 500 is set to 5000, the delay can be noticed very well. I guess a simple await sleep(500) will work too.

Instead of debounce I think throttle can be used here to solve the issue. The latter doesn't wait for the specified time when the throttled function is triggered at the first time.

@wxharry
Copy link
Collaborator Author

wxharry commented Jul 19, 2023

Hey @wxharry, thanks for your solution!

This solution works, however, it delays all loadings of features after tab switches. If 500 is set to 5000, the delay can be noticed very well. I guess a simple await sleep(500) will work too.

Instead of debounce I think throttle can be used here to solve the issue. The latter doesn't wait for the specified time when the throttled function is triggered at the first time.

Hey @tyn1998 , I implemented the throttle function for the feature adding. Would you mind testing it again?

@wxharry wxharry changed the title fix: debounce event listener function fix: throttle event listener function Jul 19, 2023
src/helpers/throttle.ts Outdated Show resolved Hide resolved
@tyn1998
Copy link
Member

tyn1998 commented Jul 23, 2023

/approve

@menbotics menbotics bot added the pull/approved If a pull is approved, it will be automatically merged label Jul 23, 2023
@menbotics menbotics bot merged commit 746d58b into hypertrons:master Jul 23, 2023
1 check passed
@tyn1998 tyn1998 mentioned this pull request Jul 23, 2023
10 tasks
@wxharry wxharry deleted the fix/debounce-listener-function branch July 23, 2023 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Category issues or prs related to bug. pull/approved If a pull is approved, it will be automatically merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] multiple header-labels are added when creating a new issue without a template
4 participants