bluebird-retry icon indicating copy to clipboard operation
bluebird-retry copied to clipboard

external interface is missing

Open vitaly-t opened this issue 7 years ago • 1 comments

It doesn't seem right that a retry loop can only be interrupted (or interacted with) form inside the callback.

There are many scenarios when it needs to happen externally.

Function retry should return an object/interface for stopping, and even monitoring the current status:

var r = retry(cb);

if(/*something happenned*/ && r.attempts > 3) {
   r.stop();
   // or even with a reason:
   // r.stop(new Error('Had to stop externally'));
}

also, how about pausing the retries?

r.pause(); // pause unconditionally
// or
r.pause(100); // pause for 100 millisecond
// and resume:
r.resume(); // to resume the retries, if currently paused

plus access to the current status:

r.getStatus() // = running | finished | paused

vitaly-t avatar Jun 18 '17 07:06 vitaly-t

At a high level I can see how this could be a nice addition to the project -- if you have an implementation with tests I'd be happy to review and include it but I'm not actively doing much if any development on this.

demmer avatar Jun 19 '17 14:06 demmer