javascript - 如何构造返回常量字符串的 Bluebird Promise?

标签 javascript promise bluebird

如果我有这样的东西

return this.retrieveArticles(blogId).then(function(response){
    return response.articles;
  }).then(_).call("findWhere", match).then(function(article){
    return {
      "article": article
    }
  });

我决定把上面的部分砍掉

    return response.articles;
  }).then(_).call("findWhere", match).then(function(article){
    return {
      "article": article
    }
  });

我该怎么做

Promise.return(articles).then(_).call("findWhere", match).then(function(article){
    return {
      "article": article
    }
  });

最佳答案

Promise.resolve(_(articles)).call("findWhere", match);

Promise.resolve(articles).then(_).call("findWhere", match);

关于javascript - 如何构造返回常量字符串的 Bluebird Promise?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27563850/

相关文章:

node.js - 如何将异步调用转换为 bluebird promise :

node.js - 如何在模型的属性方法中正确使用水线 promise ?

javascript - ASP.NET MVC Controller / View 显示本地时间

Javascript 幻灯片效果

javascript - Expressjs - 全局对象

Javascript 异常隐藏在 Promises 中。我怎样才能在没有捕获的情况下显示它们?

javascript - 如何处理 Promise 中的分支?

javascript - 包装 jQuery.ajax : Cascading inner jqXHR as a new deffered object to return

javascript - 无极 waterfall

javascript - 如何列出 webkit 可用的所有插件?