Friday, 15 January 2010

javascript - Node.js: Nested setInterval()-Methods - inner one doesn't stop -


I need an event repeatedly, at the right time in jds. I use process.hrtime () to make a higher resolution than the normal set interval method. NPM-module "Nanotimer" (,) it is set to setInterval () and setTimeOut () .

as usual. at the same time.

The code goes as follows:

  var nanometer = essential ('nanotimer'); Var Timer A = Nano Timer (); Var timer B = new nanometer (); Var Index = 0; TimerA.setInterval (function () {console.log ("a"); timerB.setInterval (function () {console.log ("B");}, '3s'); if (index> 10) { Console .log ("stop timer a"); timer; player interval (); console.log ("stop timer b"); timer bclaimer interval ();} index ++;}, '1s');  

Output:

  AAAABAAABAAABAA stop timer A stop timer B // right here B / timerB continues forever, every 3 Second BB ...  

I can not find any way to stop the inner timer. Do you have any suggestions?


No comments:

Post a Comment