szurubooru/public_html/js/Promise.js

29 lines
453 B
JavaScript
Raw Normal View History

2014-09-04 18:06:25 +02:00
var App = App || {};
App.Promise = (function(jQuery) {
function make(callback)
{
var deferred = jQuery.Deferred();
callback(deferred.resolve, deferred.reject);
return deferred.promise();
}
function wait(promise) {
return jQuery.when(promise);
}
function waitAll() {
return jQuery.when.apply(jQuery, arguments);
}
return {
make: make,
wait: wait,
waitAll: waitAll,
};
});
App.DI.registerSingleton('promise', App.Promise);