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

Added debouncer feature #16

Closed
malcommac opened this issue Mar 17, 2018 · 1 comment
Closed

Added debouncer feature #16

malcommac opened this issue Mar 17, 2018 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@malcommac
Copy link
Owner

Implement debounce features using Repeater class as core.
The debounce function is an extremely useful tool that can help throttle requests. It is different to throttle though as throttle will allow only one request per time period, debounce will not fire immediately and wait the specified time period before firing the request. If there is another request made before the end of the time period then we restart the count. This can be extremely useful for calling functions that often get called and are only needed to run once after all the changes have been made.

Example:

let debouncer = Debouncer(.seconds(10))
debouncer.callback = {
	// your code here
}

// Call debouncer to start the callback after the delayed time.
// Multiple calls will ignore the older calls and overwrite the firing time.
debouncer.call()
@malcommac malcommac self-assigned this Mar 17, 2018
@malcommac malcommac added the enhancement New feature or request label Mar 17, 2018
@malcommac malcommac added this to the 0.5.0 milestone Mar 17, 2018
@malcommac
Copy link
Owner Author

Published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant