Skip to content Skip to sidebar Skip to footer

Promise Of Promise To Simple Promise?

I've been playing with promises, and usually can figure out how to handle them well, but in this situation, I can't figure out how to remove one promise-wrapping level. Here is the

Solution 1:

level1 is a promise itself.

No it's not. Ember does use RSVP, which is Promises/A+ compatible, and that means that then callbacks are never called with a promise (or thenable). They always receive a plain value.

Promises/A+ does mandate that there are no nested promises returned from then. They are always recursively unwrapped. You can just do

promise2.then(connections =>console.log(connections));

If this really doesn't work, that would suggest that promise1 is no real (or at least no standard-conformant) promise, and you should do promise1 = Promise.resolve(promise1) first.

Post a Comment for "Promise Of Promise To Simple Promise?"