Stopping a Node.js callback by clearing setInterval -


need call on situation. if have function:

var timerid; function playback(client,log){     if (timerid) clearinterval(timerid);     timerid = setinterval(function(){         var buffer = [],             numberofloglines = log.length;         while(numberofloglines > 0){             var l = log.pop().trim(); // pull top             buffer.push(l);             if(l.split(",")[0] === "$timetosend"){ //flag timming signal                 client.send("{\"playback\":" + json.stringify(buffer) + "}");                 break;             }         }     },playbackspeed); } 

and call

clearinterval(timerid)

at other point stop callback? trying create pause/play situation start playback again invoke playback(client,log) again restart. seems work but, wondering clearing interval stop callback. don't want create log jam case of heavy "pause/play" happy people.

a call clearinterval( timerid ) stop future calls anonymous function. if there previous calls of running, these finish.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -