svecosystem / runed

Magical utilities for your Svelte applications (WIP)
https://runed.dev
MIT License
557 stars 28 forks source link

add method to fire any scheduled `use-debounce` call now #134

Open Coronon opened 2 months ago

Coronon commented 2 months ago

Describe the feature in detail (code, mocks, or screenshots encouraged)

Context

I frequently use the use-debounce hook in my application to manage delayed function executions. However, there are scenarios, such as when closing a modal, where I need to immediately trigger the scheduled debounced callback instead of waiting for the remaining debounce period. This functionality would be especially beneficial in ensuring that important callbacks are not lost or delayed when the debounce period is no longer relevant.

Request

I am requesting an enhancement to the use-debounce hook that allows for the immediate resolution of any scheduled callbacks. This could be implemented via a method (e.g., resolveNow) that forces the execution of the debounced function at the current time, bypassing any remaining debounce delay.

What type of pull request would this be?

Enhancement

Provide relevant links or additional information.

https://runed.dev/docs/utilities/use-debounce

huntabyte commented 1 month ago

I think this is a reasonable request! Open to PRs if anyone is interested in contributing this!