手写简单的promise

const PENDING = 'pending';
const RESOLVED = 'resolved';
const REJECTED = 'rejected';
function newPromise(fn){
const _that = this;
_that.state = PENDING;
_that.value = null;
_that.resolvedCallbacks = [];//用来保存then中的回调
_that.rejectedCallbacks = [];//用来保存then中的回调
function resolve(value){
if(value instanceof newPromise){
value.then(resolve,reject);

手写简单的promise最先出现在Python成神之路

版权声明:
作者:admin
链接:https://www.techfm.club/p/21486.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>