tiger
Version:
A full port of Spine.js MVC framework to Titanium Mobile, with enhancements
50 lines (44 loc) • 1.33 kB
JavaScript
// Generated by CoffeeScript 1.6.3
(function() {
var Tiger, awaitAjax;
Tiger = this.Tiger || require('./tiger');
awaitAjax = {
awaitAjax: function(options, cb, queue) {
var rv;
if (queue == null) {
queue = false;
}
rv = new iced.Rendezvous();
options.success = rv.id('success').defer(data, statusText, xhr);
options.error = rv.id('error').defer(xhr, statusText, data);
if (queue) {
this.Q.ajaxQueue(options);
} else {
new this(options);
}
await(rv.wait(defer(status)));
return cb(status, xhr, statusText, data);
},
awaitGet: function(options, cb, queue) {
options.method = 'GET';
return this.awaitAjax(options, cb, queue);
},
awaitPost: function(options, cb, queue) {
options.method = 'GET';
return this.awaitAjax(options, cb, queue);
},
awaitQueuedAjax: function(options, cb) {
return this.awaitAjax(options, cb, true);
},
awaitQueuedGet: function(options, cb) {
return this.awaitGet(options, cb, true);
},
awaitQueuedPost: function(options, cb) {
return this.awaitPost(options, cb, true);
}
};
Tiger.Ajax.extend(awaitAjax);
if (typeof module !== "undefined" && module !== null) {
module.exports = awaitAjax;
}
}).call(this);