-
Notifications
You must be signed in to change notification settings - Fork 46
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
Namespace for timers #30
Comments
I recommend implementing this on top of d3-timer, rather than making it a feature intrinsic to d3-timer. Something like a “timer manager” that functions similarly to the d3.timer constructor but, like you say, takes a timer name and implicitly stops any existing timer with the same name before returning the new timer. (Or perhaps it would use timer.restart to preserve the invocation order of the existing timer.) The timer manager would presumably also want to wrap timer.stop so that stopping a timer would remove it from the manager’s registry. And yep, for @observablehq, we’re using generators rather than timers, and since generators are pull-based they cleanup after themselves naturally. You can still create a timer (or add an event listener etc.) inside a cell; the only caveat is that you have to use a try-finally block to stop your timer (or remove your event listener) when the generator is terminated. |
Cool - I'll throw something like that into jetpack. thanks! |
Excellent. Thank you! |
I've started using hot reloading to see how my code changes the page without triggering a full refresh.
This requires some bookkeeping if there is a
timer
on the page to remove old timers:Event listeners don't have this problem:
Timers could do something similar if they took a fourth argument:
Not sure if you've found a better solution while working on express; it looked like you were using
while (true)
in a generator instead of atimer
.The text was updated successfully, but these errors were encountered: