javascript - Node.js: running setInterval while certain variable is true? -
i have setinterval function , isrunning variable. how stop setinterval when isrunning gets set false?
thanks.
see comments inline:
var isrunning = true; // define outside can accessed inside setinterval var interval = setinterval(function() { // code here // check if variable false, clear interval if (isrunning == false) { clearinterval(interval); } }, 100);
Comments
Post a Comment