meteor / promise

ES6 Promise polyfill with Fiber support
MIT License
63 stars 15 forks source link

Class context fix for await/awaitAll #20

Closed jasonk closed 4 years ago

jasonk commented 7 years ago

I was trying to use makeCompatible to add Meteor support to the bluebird promises library, like this:

const Promise = require( 'bluebird' );
const Fiber = require( 'fibers' );
require( 'meteor-promise' ).makeCompatible( Promise, Fiber );

This didn't work correctly and resulted in the error message this.resolve is not a function whenever I attempted to use Promise.await or Promise.awaitAll. I tracked the error down to the implementation of await and awaitAll using this.resolve and this.all, and apparently assuming that the context would have this set to the promise implementation when that happened. In my environment I found this wasn't the case (instead I had this === global). By making the small change that is in this PR (simply replacing this with Promise in those two class methods) I was able to get it to work.

CLAassistant commented 5 years ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant commented 5 years ago

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.