Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate bluebird for promises #1742

Closed
pspeter3 opened this issue Oct 17, 2013 · 12 comments
Closed

Investigate bluebird for promises #1742

pspeter3 opened this issue Oct 17, 2013 · 12 comments

Comments

@pspeter3
Copy link

Bluebird seems to have the strongest performance benchmarks for promises and seems to match the coming DOM Promises in V8 the closest. I'm wondering if it is a good choice for the interim as a Promises/A+ implementation.

@benjamingr
Copy link
Contributor

+1 for this

@refack
Copy link
Contributor

refack commented May 7, 2014

👎 prefer native promises - #1699

@benjamingr
Copy link
Contributor

@refack why? They're slower and don't do unhandled rejection detection which is one of the most important features of Bluebird, they also provide worse stack traces.

Using Bluebird would mean deleting code and removing cruft, you can remove all the promise code from there and simply do Promise.promisifyAll("mongoose"); which would generate that code on the fly.

@refack
Copy link
Contributor

refack commented Jun 2, 2014

@benjamingr, native, because their native. They will become the standard (and improve in performance I'm sure).
I also agree with aheckmann's goal of factoring out userland functionality into other modules, and I belive your example of Promise.promisifyAll("mongoose"); answers your own question, that is no need to integrate internally, if it could cloud be solved as so simply in userland.

@drewhamlett
Copy link

+1 for Bluebird

@Globegitter
Copy link

Any update on this? Bluebird does seem like the best solution out there currently.

@klimashkin
Copy link

+1 for Bluebird

@klimashkin
Copy link

Also Bluebird have fast cute opportunity to use callback on promise: nodeify
For example:

Model.prototype.save = function save (fn) {
  return new Promise(function (resolve, reject) {
    var options = {}
    if (this.schema.options.safe) {
      options.safe = this.schema.options.safe;
    }
    ...
  }).nodeify(fn);
};

After that we will be able to call save so:

model.save()
     .spread(function (savedDoc, num){...})
     .catch(function (err){...})

and so (classic):

model.save(function (err, savedDoc, num){...})

@benjamingr
Copy link
Contributor

@petkaantonov - I recall an argument about .nodeify returning a promise. I see the docs still specify that it does. Is this case in the comment above supported?

@petkaantonov
Copy link

yes it always returns the promise

@j
Copy link
Contributor

j commented Nov 24, 2014

+1 ooooya.

@vkarpov15
Copy link
Collaborator

See #2688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants