bluebird-retry
bluebird-retry copied to clipboard
external interface is missing
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
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.