gdibble / backbone-ajaxretry Goto Github PK
View Code? Open in Web Editor NEWExponentially retry Backbone.ajax & $.ajax requests
License: MIT License
Exponentially retry Backbone.ajax & $.ajax requests
License: MIT License
Users have reported JS error.
Temporary fix (until this is resolved) includes adding the following first-line to the Backbone.ajax
extend-function before the return
:
Backbone.$ = $; // <<< add as temp-fix
return Backbone.$.ajax.apply(Backbone.$, args);
just in case someone wants a linear perpetuation
apologies w/ v1.2.0. when using $.get
or $.post
shortcuts, first argument is a string and thus internal extender
function had a bug.
a POST with a response-body, PUT, GET, DELETE all work as expected,
but a POST with res.status 200 and no response-body keeps retrying the successful req.
considering checking jqXHR.status < 300 >>> _exhausted()
allow jqXHR.type
, jqXHR.url
, etcetera
$.ajax returns arguments to the error
callback:
( jqXHR jqXHR, String textStatus, String errorThrown )
These arguments should be passed forward to the exhaust
callback such that the developer can do something like:
function onExhaust(jqXHR, textStatus, errorThrown) {
console.log(jqXHR, textStatus, errorThrown);
if (jqXHR.status > 500) {
//do something about Server Error
} else if (jqXHR.status > 400) {
//do something about Client Error
}
}
myModel.fetch({ exhaust:onExhaust });
use vanilla js fns
For example, in my app I want to use the default of { retryCount:3 }
in most cases,
but this particular fetch
I would like to try more or less, i.e.
myModel1.fetch({
retryCount: 99
});
// ||
myModel2.fetch({
retryCount: 0
});
Any setting, default or via .set
, should allow overloading (thus superseding settings) from the current instantiation.
provide compress library for Backbone apps requiring library on-the-fly and developers who include this module via HTML or lazy-loading.
initial estimate shows 51% reduction.
Not just Backbone.$.ajax
requests; also allow retry/exhaust
callback for $.ajax
usage request due to 400-class codes being retried when 403 forbidden returned, etc:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.