Which is the best promise package right now?

What’s the best package for using promises?

  1. https://atmospherejs.com/deanius/promise with 26 stars?
  2. https://atmospherejs.com/okgrow/promise with 13 stars?
  3. https://atmospherejs.com/meteor/promise from MDG with 9 stars?

No 3 is the official package but it seems to be missing a lot of functionality that both no 1 and no 2 have.

As I want to give “promises” a try I’m wondering which one I should use right now?

TIA

  1. The okgrow version seems to be deprecated in favor of the deanius:promise package. See https://github.com/okgrow/meteor-promise/issues/6

  2. I have not been able to make the deanius:promise package work. I have filed an issue at the github page, https://github.com/deanius/meteor-promise/issues/20 for clarification.

  3. This does seem to be an official Meteor package, but it has extremely scant documentation. There are hints dribbled around the forum. See How do I properly use an NPM module that returns a Promise? , Fibers and meteor-promise npm pacakge

2 Likes

does ES6 not work w/o React installed? I’d just use ES6

1 Like

Sorry - I don’t think that I explained the problem well. I know about ES6 promises, but I don’t (yet) see how it fits the context of my situation.

I have an application with server-side methods that use a library that returns promises. My client-side code wants to call the server code with something like Meteor.call(), but it needs to be able to handle the promise that’s returned…

The two libraries (#2 & #3 above) seem to offer that, but there isn’t any documentation and/or working sample code.

You can just use the basic promise library and use async/await.

Meteor.methods({
  'some method': function () {
    let getSomething = Promise.async(someFunction);
    return Promise.await(getSomething());
  }
});

Then on your client just do a plain callback.

Meteor.call('some method', function (err, res) {
  // do whatever.
  // `res` is the result returned to `.then()` in the promise.
});
1 Like

Thanks for this response, but I’m confused about what I get in the function(err, res) {...} callback.

I have console.log(`Promise completed - "${err}" "${res}"`); within that callback, and get this:

Promise completed - "undefined" "function () {
  return Promise.asyncApply(
  fn, this, arguments,
  allowReuseOfCurrentFiber
  );
}"

The first argument ${err} is undefined, as expected; the ${res} appears to be some kind of function. How should I use that? Many thanks.

That’s strange, as deanius stated that he works for okgrow:

Yes but… okgrow just updated their page to say that deanius should be used. https://github.com/okgrow/meteor-promise

The issue that I raised on deanius has not yet had a response. https://github.com/deanius/meteor-promise/issues/20

The MDG meteor package has no documentation beyond a recommendation to watch their video. Neither do they offer any sample code that can be walked through/executed. My issue at https://github.com/meteor/promise/issues/8 has not had a response, either.

From my viewpoint, I think it’s safe to say that there is no support for Promises in Meteor at the moment. I would love to have someone refute this: point us all to working sample code that shows how to do it.

1 Like

No answers yet on this topic, but there’s a very thoughtful conversation on the topic at: Start using async/await instead of promises and callbacks

Dean here- the deanius version is the latest, and is looking for a maintainer. I’m still interested in the discussions about the future of async in Meteor, but would love to empower someone else to write code and handle questions/issues as they arise.

1 Like