Interval Loop Manager
A class to manage a loop with some interval.
Purpose
I want set a loop with some interval.
Sometimes, I want to stop the loop or change the interval.
How to use
Setup
Require interval-loop-manager.
const IntervalLoopManager =
I explain interval loop manager by setting a loop of the following function.
const yourFunction = { // some process}
Start a loop
In case you want to set loop with 5 seconds interval.
const managedLoop = yoruFunction interval: 5000
or
var managedLoop = yourFunction managedLoopstart interval: 5000
Stop the loop
managedLoop
Restart the loop
managedLoop
or
managedLoopstart
Change the interval
Ways to change the interval to 7 seconds.
In case you want to change it as soon as possible.
managedLoop
In case you allow current loop to finish.
managedLoop
Detect whether the loop is running or not
if managedLoop console else console
License
MIT
Reference
http://stackoverflow.com/questions/1280263/changing-the-interval-of-setinterval-while-its-running