adobe-webplatform / Snap.svg

The JavaScript library for modern SVG graphics.
http://snapsvg.io
Apache License 2.0
13.94k stars 1.15k forks source link

Need a way to stop/restart the "hub garbage collector" interval timer #520

Open sparr opened 7 years ago

sparr commented 7 years ago

https://github.com/adobe-webplatform/Snap.svg/blob/8c67c8ceaa6b4b2c7202c79297fe86532dacd03c/src/svg.js#L1321-L1330

No handle is kept for this timer, so there is no clean way to terminate it.

Also, if we can terminate it then we should be able to restart it.

ibrierley commented 7 years ago

Just wondering, if it's garbage collecting every 10 secs, whats the main need to terminate it. What problems are you experiencing out of interest ?

sparr commented 7 years ago

In my immediate case, I'm running Snap in a non-browser environment that won't terminate while there are timers still running.

In general, even in a browser, it's bad practice to leave things running in the background long after the script has finished being used.

ibrierley commented 7 years ago

Sounds like a good reason!

ThomasBrierley commented 7 years ago

hub isn't referenced too much, should be quite simple to turn this into a self invoking / self terminating timeout, either using a setter function or an explicit add to hub/cache function.

I'll have a go at knocking this off quickly as it's a small one.