Droontar Droontar - 4 months ago 61
Javascript Question

Avoiding callback hell. Meteor.call promise

I've been trying to avoid callback hell in Meteor but first, I'll explain my problem:

I have some Meteor methods declared in server, and I invoke them using Meteor.call in client, but the main problem is I have tons of callbacks making debugging a really difficult task to make (and manteinance too...). This wouldn't be an issue if I work with a "small" project, but I'm building a big one and I was planning on using promises but for my surprise... it's not working since Meteor.call only accepts callbacks.

I've read a lot of posts here and in Meteor forums and none of them can help me... is there any solution to this? (I tried deanius:promise package and it's still the same...)

Edit: using Meteor 1.4.2
Edit2: Here's the example code I'm trying to run, separating method declarations(server) from method invocations(client).


Nowadays the ES7 Async/Await is there to help the "callback trouble". See explained very well here: http://rossboucher.com/await/#/10

async function () {
    let result1 = await Do.Something(1);
    let result2 = await Do.Something(2);