标签:blog io ar sp java on div log bs
var Promise=function(args)
{
this.callback=[];
var _this=this;
setTimeout(function() {
_this.done();
}, 0);
};
Promise.prototype.then=function(result)
{
this.callback.push(result);
return this;
};
Promise.prototype.when=function()
{
throw new Error(‘Not implemented‘);
};
Promise.prototype.done=function()
{
console.log(this.callback.join(‘,‘));
return this;
};
new Promise().then(10).then(11).then(12);
Javascript Promise Implementation
标签:blog io ar sp java on div log bs
原文地址:http://www.cnblogs.com/hahazhu/p/4143640.html