anima-promise
v3.0.3 promise
anima-promise
移动端的 Promise/A+ 实现,符合标准Promise的规范
Install
$ tnpm install anima-promise --save
Normal Usage
下面是ES6代码的例子,也可以采用ES5进行开发
import Promise from 'anima-promise';
function foo() {
return new Promise(resolve => {
setTimeout(() => {
resolve(1);
});
});;
}
foo().then(value => {
console.log(value); // 1
});
// Deferred
const Deferred = function() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
this.then = this.promise.then.bind(this.promise);
this.catch = this.promise.catch.bind(this.promise);
};
function far() {
const d = new Deferred();
setTimeout(() => {
d.resolve('a')
}, 10);
return d.promsie;
}
foo().then(value => {
console.log(value); // a
});
npm i anima-promise
Source Code
gitlab.alibaba-inc.com/anima...Metadata
- MIT
- >=4.0.0
- [email protected]
- released 10/18/2016