admin管理员组文章数量:1327945
Switching over to Bluebird from Q, I just want to make sure it's culturally correct: Is there an equivalent to Q.when(someValue);
or Q(someValue);
?
Is it Promise.resolve(someValue);
?
Switching over to Bluebird from Q, I just want to make sure it's culturally correct: Is there an equivalent to Q.when(someValue);
or Q(someValue);
?
Is it Promise.resolve(someValue);
?
- This isn't a duplicated question: I'm asking what pattern should be used when you have a value that should be immediately returned, which is dissimilar to the question @gruenbaum you provided as duplicate. Please advise. – asking Commented May 28, 2015 at 1:35
-
Answers there do explain how to actually use Bluebird instead of Q. And I haven't used Q much, but you might be correct, i.e. you could use
Promise.resolve(value)
to return a simple resolved promise (which can be.then(..
) if that's what Q.when does. Also if you post more context, like what you're trying to do someone might tell you how to better use Bluebird instead of finding equivalents, as Bluebird tends to fix a lot of anti-patterns used in other Promise libraries. – laggingreflex Commented May 28, 2015 at 2:57 - Thanks @ laggingreflex, but although answers there may explain how to use Bluebird, the question asked there is "how to create an empty promise" - that's not what I'm asking, so the answers there shouldn't answer my question, and I'm asking "how to create a fulfilled promise in Bluebird" - totally different question, which means I haven't asked a duplicate question. So, can we all stop trolling for points? I just want to have a conversation about code and the culture of an API. – asking Commented May 28, 2015 at 5:03
- Does this help somehow: stackoverflow./questions/22684643/… ? – OddDev Commented May 28, 2015 at 10:02
- Yes, it's the similar question. You're just asking how to use Q which is Q.when (they're the same function) in Bluebird - which is what that question asks. – Benjamin Gruenbaum Commented May 28, 2015 at 10:40
1 Answer
Reset to default 12Is it
Promise.resolve(someValue);
?
Yes.
本文标签: javascriptWhat is the Bluebird equivalent of QwhenStack Overflow
版权声明:本文标题:javascript - What is the Bluebird equivalent of `Q.when`? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742222992a2435571.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论