node-multispinner icon indicating copy to clipboard operation
node-multispinner copied to clipboard

Add `stop` method

Open twolfson opened this issue 9 years ago • 1 comments

I'm using async for my async tasks and have 2 scenarios where a stop method would be helpful:

  • I already know when the tasks are done and don't want to listen to multiprocess for done (so I can have 1 function to handle next case)
  • Tasks are cancelled due to an fail fast error
    • I need to be able to log an error without worry of it being overwritten by a pending setTimeout

This should be plausible via a stop method which runs clearTimeout and loop()'s success case (i.e. this.update.done();)

twolfson avatar Dec 13 '16 08:12 twolfson

For those curious, this is a monkey-patch workaround that is equally effective:

    // Monkey-patch over multispinner instance to prevent waiting for it to finish
    // https://github.com/codekirei/node-multispinner/blob/318a09dd41acd41eab90ca543f61eff25a12a860/index.js#L94-L112
    multispinner.allCompleted = function () { return true; };
    multispinner.loop();
    multispinner.loop = function () {};

twolfson avatar Dec 13 '16 08:12 twolfson