作家
登录

30分钟,让你彻底明白Promise原理

作者: 来源: 2017-06-08 10:02:44 阅读 我要评论

        if (cb === null) { 
  •  
  •             cb = state === 'fulfilled' ? callback.resolve : callback.reject; 
  •  
  •             cb(value); 
  •  
  •             return
  •  
  •         } 
  •  
  •         ret = cb(value); 
  •  
  •         callback.resolve(ret); 
  •  
  •     } 
  •  
  •   
  •  
  •     function resolve(newValue) { 
  •  
  •         if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { 
  •  
  •             var then = newValue.then
  •  
  •             if (typeof then === 'function') { 
  •  
  •                 then.call(newValue, resolve, reject); 
  •  
  •                 return
  •  
  •             } 
  •  
  •         } 
  •  
  •         state = 'fulfilled'
  •  
  •         value = newValue; 
  •  
  •         execute(); 
  •  
  •     } 
  •  
  •   
  •  
  •     function reject(reason) { 
  •  
  •         state = 'rejected'
  •  
  •         value = reason; 
  •  
  •         execute(); 
  •  
  •     } 
  •  
  •   
  •  
  •     function execute() { 
  •  
  •         setTimeout(

      推荐阅读

      2017年上半年重大黑客事件盘点

    16. 美国法律论坛71万账户泄漏,涉国度安然局、FBI等本年4月,达拉斯紧急警备孀体系被黑客入侵。导致该城市的156个紧急戒备器被激活,警笛声持续一个小时,激发市平易近惊恐。 在以前的201>>>详细阅读


    本文标题:30分钟,让你彻底明白Promise原理

    地址:http://www.17bianji.com/lsqh/35631.html

  • 关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)