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

feat!: various debounce improvements (DO NOT SQUASH) #107

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Conversation

aleclarson
Copy link
Member

@aleclarson aleclarson commented Jul 13, 2024

Tip

The owner of this PR can publish a preview release by commenting /publish in this PR. Afterwards, anyone can try it out by running pnpm add radashi@pr<PR_NUMBER>.

Summary

  • Continue debouncing (in future calls) after cancel is called. Previously, cancel would disable debouncing, so future calls would be immediate.
  • Do not have flush call the underlying function if no call is pending.
  • Expose a reference to the underlying function with the new handler property.

Related issue, if any:

Resolves #105

Resolves sodiray/radash#362

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed

Does this PR introduce a breaking change?

Yes

Bundle impact

Status File Size Difference (%)
M src/curry/debounce.ts 275 +53 (+23%)

@aleclarson aleclarson force-pushed the feat/debounce-handler branch from d3f076c to 1de9de9 Compare July 13, 2024 03:45
@aleclarson aleclarson added the BREAKING CHANGE Not backwards compatible label Jul 13, 2024
@aleclarson aleclarson force-pushed the feat/debounce-handler branch from 10a9794 to b100467 Compare July 13, 2024 23:51
@aleclarson aleclarson force-pushed the feat/debounce-handler branch from b100467 to 586b258 Compare July 13, 2024 23:51
@aleclarson aleclarson changed the title feat: various debounce improvements (DO NOT SQUASH) feat!: various debounce improvements (DO NOT SQUASH) Jul 14, 2024
Comment on lines +31 to +36
* Debounced functions have these methods:
*
* - The `cancel` method cancels the debounced function.
* - The `flush` method calls the underlying function immediately if it was
* debounced, otherwise it does nothing.
* - The `isPending` method checks if the debounced function is pending.
Copy link
Contributor

Choose a reason for hiding this comment

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

Include handler here? I assume you're publicly exposing it since flush no longer guarantees execution?

Add to the docs as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah good catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING CHANGE Not backwards compatible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix debounce cancel Challenging the Logic Behind "active" in Debounce Function
2 participants