热门搜索 :
考研考公
您的当前位置:首页正文

typescript优化promise接口

来源:东饰资讯网

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

// 不推荐
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) {});
Top