
Make a request using PatienceJS library.
Note: Re-attempts are not enabled unless explicitly called by your application.
// Default Retry Options:
{{ { max: 2, interval: 500 } | json }}
// Sample Angular.js code for this request
{{ ctrl.demoRequests.basic.toString() | parseFunctionBody | removeTabs }}
Make a request using retry library with custom options.
// Sample Angular.js code for this request
{{ ctrl.demoRequests.customRetry.toString() | parseFunctionBody | removeTabs }}
A Re-attempt is a secondary abstraction available via the retry library. It allows you to be notified when the retry strategy fails while the library starts to re-attempt the request at the provided re-attempt interval.
A re-attempt also allows for an optional intervalMultiplicator option.
If provided, intervalMultiplicator is an integer by which the interval will be increased after each re-attempt.
// Default re-attempt configuration:
{{ { max: 2, interval: 1000, intervalMultiplicator: 1 } | json }}
// Sample Angular.js code for this request
{{ ctrl.demoRequests.retryAndReAttempt.toString() | parseFunctionBody | removeTabs }}
This request will be made using custom retry and custom re-attempt options.
// Sample Angular.js code for this request
{{ ctrl.demoRequests.customRetryAndReAttempt.toString() | parseFunctionBody | removeTabs }}
The explicit syntax of the retry library API can feel repetitive if you are using the same type of API calls in several places in your app.
For this case, the .addStrategy(strategyName, options) and
.runStrategy(strategyName) methods are available.
As outlined in the README.md documentation, strategies allow you to add preset options for: requests, group, retry, and re-attempt.
You can start by adding a strategy with .addStrategy(strategyName, options) method call.
Adding strategies can be especially powerful if you use them as an independent abstraction which your application leverages.
You can reuse these strategies by using the
.runStrategy(strategyName) rather than the default .run()
method to initiate your AJAX call.
// Add a strategy
{{ ctrl.addStrategy.toString() | parseFunctionBody | removeTabs }}
// Call the strategy which will configure your call automatically per the presets
{{ ctrl.demoRequests.customStrategy.toString() | parseFunctionBody | removeTabs }}