Ox.Request: if data is in cache, don't fail if it gets removed before timeout
This commit is contained in:
parent
5424023903
commit
c69858ca2d
1 changed files with 5 additions and 3 deletions
|
@ -106,7 +106,8 @@ Ox.Request = (function() {
|
|||
@*/
|
||||
send: function(options) {
|
||||
|
||||
var options = Ox.extend({
|
||||
var data,
|
||||
options = Ox.extend({
|
||||
age: -1,
|
||||
callback: null,
|
||||
id: Ox.uid(),
|
||||
|
@ -122,7 +123,7 @@ Ox.Request = (function() {
|
|||
if (pending[options.id]) {
|
||||
setTimeout(function() {
|
||||
Ox.Request.send(options);
|
||||
}, 0);
|
||||
});
|
||||
} else {
|
||||
requests[options.id] = {
|
||||
url: options.url,
|
||||
|
@ -132,8 +133,9 @@ Ox.Request = (function() {
|
|||
options.age == -1
|
||||
|| options.age > +new Date() - cache[req].time
|
||||
)) {
|
||||
data = cache[req].data;
|
||||
setTimeout(function() {
|
||||
callback(cache[req].data, true);
|
||||
callback(data, true);
|
||||
});
|
||||
} else {
|
||||
pending[options.id] = true;
|
||||
|
|
Loading…
Reference in a new issue