美文网首页
typescript优化promise接口

typescript优化promise接口

作者: Zszen | 来源:发表于2018-11-14 01:20 被阅读87次

参考中做出了一些建议,我摘过来供参考:

// 不推荐
asyncRun().then(function(value) {}, function(error) {});
// 推荐
asyncRun().then(function(value){}).catch(function(rejected) {});
// 不推荐
asyncRun()
    .then(function(value) {}, function(error) {})
    .then(function(value) {}, function(error) {})
    .then(function(value) {}, function(error) {});

// 推荐
asyncRun()
    .then(function(value){})        
    .then(function(value){})
    .then(function(value){})
    .catch(function(rejected) {});

参考:http://www.cnblogs.com/ifantastic/p/6077707.html

相关文章

网友评论

      本文标题:typescript优化promise接口

      本文链接:https://www.haomeiwen.com/subject/zoarfqtx.html