|
|
var $ = require('yoho-jquery');
|
|
|
|
|
|
$.extend({
|
|
|
defer: function(func) {
|
|
|
return function() {
|
|
|
var defer = $.Deferred(); // eslint-disable-line
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
|
|
|
args.push(defer.resolve, defer.reject);
|
|
|
func && func.apply(undefined, args);
|
|
|
return defer.promise();
|
|
|
};
|
|
|
},
|
|
|
reject: function() {
|
|
|
var defer = $.Deferred(); // eslint-disable-line
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
|
|
|
return defer.reject.apply(defer, args).promise();
|
|
|
},
|
|
|
resolve: function() {
|
|
|
var defer = $.Deferred(); // eslint-disable-line
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
|
|
|
return defer.resolve.apply(defer, args).promise();
|
|
|
}
|
|
|
}); |
...
|
...
|
|