weilao-deferred
v0.1.2
Published
Just like jQuery.deferred() but smaller.
Downloads
1
Readme
Weilao Deferred
Just like jQuery.deferred() but smaller.
How to use
(function () {
// Define an async function using Deferred()
function getResponseTextAsync() {
var defer = Deferred();
setTimeout(function () {
if (Math.random() > 0.5) {
defer.resolve('Response Text');
} else {
defer.reject('Fail Response!');
}
}, 1000);
return defer;
}
// Usage
getResponseTextAsync()
.done(alert)
.fail(alert)
.always(function () {
alert('Always~');
});
})();
Compatibility
IE9+ With ieBetter it would work in IE8-