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

reset or renew a timeout #18

Closed
emahuni opened this issue Jul 19, 2022 · 3 comments
Closed

reset or renew a timeout #18

emahuni opened this issue Jul 19, 2022 · 3 comments

Comments

@emahuni
Copy link

emahuni commented Jul 19, 2022

This enables rekindling a dead timeout as if it's new

timeout.set('huga', ()=>console.log('huga done!'), 5000);
// ... later on after the whole thing is dead, maybe after 12000ms
timeout.renew('huga')
// if this was instantiated to t...
t.renew()

That will just reinstantiate the timeout and replace it in mem.

optionally we could set new delay

timeout.renew('huga', 400)
// if this was instantiated to t...
t.renew(400)
@emahuni
Copy link
Author

emahuni commented Jul 19, 2022

Notice this is like what set does, but without another callback, and it doesn't replace any instances, it should just modify it.

@rommelsantor
Copy link
Owner

This makes sense to me. We do have a restart() that will restart for a timeout that has not yet executed, but there is no way to reset() a timeout that has already executed.

I'd probably just call it reset() rather than renew().

@rommelsantor
Copy link
Owner

@emahuni Added in v2.7.0. Thanks!

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

No branches or pull requests

2 participants