-
Notifications
You must be signed in to change notification settings - Fork 41
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
d3.interval().restart() restarts an interval as a timer instead #39
Comments
d3.interval returns a Timer, it just happens that that Timer comes pre-registered with a callback that will restart the Timer every time it fires before invoking your callback function. So, if you call timer.restart where the timer was returned by d3.interval, it will just fire once rather than fire repeatedly. If you want to restart an interval, could you just create a new interval by calling d3.interval instead? |
Sure, that approach works pretty painlessly! As a user, though, it's not clear to me from the documentation that that's how Thanks for responding so quickly! |
Would it not be better to change the code so that restarting an interval would restart it "as an interval"? I'm struggling to see the implication in terms of code, though. |
Fixed in https://github.com/d3/d3-timer/releases/tag/v2.0.0 |
It's still doesn't behave the same as stopping the timer and calling If you set
But if you restart after This doesn't happen if you stop the interval and create a new one with the same parameters. |
I ran into an issue with
d3.interval
not working as expected when callingrestart
. If I create a new interval, it works as expected -- firing the callback every delay milliseconds:This outputs:
If I call
restart
on this instance, passing the same callback and delay, I would expectintervalTest
to restart following the same behavior. However, it appears to start a timer (or an interval with 0ms delay) instead.Outputs:
And so on until the callback reaches its stopping point.
If I'm actually misunderstanding and this isn't how
interval
is supposed to be used, perhaps something could be added to the docs to clarify?Let me know if you have any questions, and thanks for your work on this module!
The text was updated successfully, but these errors were encountered: