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);?

Share Improve this question edited May 27, 2015 at 5:08 thefourtheye 240k53 gold badges465 silver badges500 bronze badges asked May 27, 2015 at 4:27 askingasking 1,4453 gold badges13 silver badges21 bronze badges 6
  • 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
 |  Show 1 more ment

1 Answer 1

Reset to default 12

Is it Promise.resolve(someValue);?

Yes.

本文标签: javascriptWhat is the Bluebird equivalent of QwhenStack Overflow