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

ES6 shim without global Promise #451

Closed
guybedford opened this issue Apr 29, 2015 · 5 comments
Closed

ES6 shim without global Promise #451

guybedford opened this issue Apr 29, 2015 · 5 comments

Comments

@guybedford
Copy link
Contributor

Is it possible to require the es6-shim in a way that doesn't override the global Promise?

@briancavalier
Copy link
Member

Hey @guybedford. There's no way yet, but we're planning to provide one.

In the meantime, would it work for you to write your own tiny wrapper module that does the following?

var unhandledRejection = require('when/lib/decorators/unhandledRejection');
module.exports = unhandledRejection(require('when/lib/Promise'));

If so, then that'd get you an ES6 compliant Promise with the default unhandled rejection reports enabled, without overriding the global.

If that's not an option, let me know, and I'll bump up the priority on this.

@guybedford
Copy link
Contributor Author

Thanks @briancavalier for the quick response - yes that will work great. Note it is specifically for Node that this is needed - in the browser we do want the Promise global to be polyfilled.

In terms of implementing the shim without overriding the global, what would be really useful is setting global.Promise only if it is not already set, and then perhaps providing a polyfill interface like global.when.Promise that could also be relied on, although that may not even be necessary.

@briancavalier
Copy link
Member

yes that will work great

Cool, thanks for confirming.

what would be really useful is setting global.Promise only if it is not already set

Yep, I totally agree. That's the route we'll go. See #442 for a bit more on why we originally decided to forcibly overwrite global Promise.

@briancavalier
Copy link
Member

Is it cool w/you if we close this and track progress in #442?

@guybedford
Copy link
Contributor Author

Sure, thanks for your help!

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

2 participants