hxnodejs-backoff 2.5.0-alpha

Externs for the backoff NPM module

Released 2016-04-04.

To install, run:

haxelib install hxnodejs-backoff 2.5.0-alpha

See using Haxelib in Haxelib documentation for more information.

Maintainerlpetre
Websitehttps://github.com/proletariatgames/hxnodejs-backoff
Current version2.5.0-alpha
StatisticsInstalled 11 times
LicenseMIT
Tags backoff, exponential, fibonacci, hxnodejs, nodejs, retry

README.md

Haxe/hxnodejs externs for the backoff npm library

Tested using backoff version 2.5.0

Example:

import js.npm.Backoff;

var fibonacciBackoff = js.npm.Backoff.fibonacci({
    randomisationFactor: 0,
    initialDelay: 10,
    maxDelay: 300
});
 
fibonacciBackoff.failAfter(10);
 
fibonacciBackoff.on(BackoffEvent.Backoff, function(number, delay) {
    // Do something when backoff starts, e.g. show to the 
    // user the delay before next reconnection attempt. 
    trace(number + ' ' + delay + 'ms');
});
 
fibonacciBackoff.on(BackoffEvent.Ready, function(number, delay) {
    // Do something when backoff ends, e.g. retry a failed 
    // operation (DNS lookup, API call, etc.). If it fails 
    // again then backoff, otherwise reset the backoff 
    // instance. 
    fibonacciBackoff.backoff();
});
 
fibonacciBackoff.on(BackoffEvent.Fail, function() {
    // Do something when the maximum number of backoffs is 
    // reached, e.g. ask the user to check its connection. 
    trace('fail');
});
 
fibonacciBackoff.backoff();