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

Add Promise.prototype.finally support #9663

Merged
merged 4 commits into from Feb 13, 2018

Conversation

Projects
None yet
3 participants
@hwillson
Member

hwillson commented Feb 12, 2018

Adds Promise.prototype.finally support to Meteor's promise package. Let me know if I missed anything. Thanks!

Fixes #9639.

hwillson added some commits Feb 12, 2018

Add Promise.prototype.finally support
Adds `Promise.prototype.finally` support to Meteor's
`promise` package.

Fixes #9639.
@benjamn

This comment has been minimized.

Member

benjamn commented Feb 12, 2018

Looking at https://github.com/zloirock/core-js/blob/master/modules/es7.promise.finally.js for comparison, there's some extra logic to allow Promise subclasses to override the static Promise.resolve method. Essentially, instead of calling exports.Promise.resolve(f()), it would be better to call this.constructor.resolve(f()), since this.constructor might be a subclass that inherits from Promise.

The core-js implementation also checks if this.constructor[Symbol.species] is defined, just in case that should be used instead of this.constructor. Here's an explanation of why Symbol.species exists.

However, it strikes me that this is a lot of pedantry/pageantry just to call Promise.resolve, and there may be a way to rewrite this code so that it doesn't need to call Promise.resolve explicitly. That would probably be a worthwhile PR to core-js, too, if it works.

I'll push a commit in a few minutes if I can figure this out.

@hwillson

This comment has been minimized.

Member

hwillson commented Feb 12, 2018

That would be awesome @benjamn! I was following the promise/lib/finally approach, but the core-js implementation does seem safer. Let me know how far you get and if there's anything I can dive back into. Thanks!

benjamn and others added some commits Feb 12, 2018

Merge pull request #1 from meteor/avoid-explicit-species-logic-in-pro…
…mise-finally

Aid Promise subclassability by avoiding Promise.resolve in #finally.

@benjamn benjamn merged commit 8b95173 into meteor:devel Feb 13, 2018

17 checks passed

CLA Author has signed the Meteor CLA.
Details
ci/circleci: Docs Your tests passed on CircleCI!
Details
ci/circleci: Get Ready Your tests passed on CircleCI!
Details
ci/circleci: Group 0 Your tests passed on CircleCI!
Details
ci/circleci: Group 1 Your tests passed on CircleCI!
Details
ci/circleci: Group 10 Your tests passed on CircleCI!
Details
ci/circleci: Group 11 Your tests passed on CircleCI!
Details
ci/circleci: Group 2 Your tests passed on CircleCI!
Details
ci/circleci: Group 3 Your tests passed on CircleCI!
Details
ci/circleci: Group 4 Your tests passed on CircleCI!
Details
ci/circleci: Group 5 Your tests passed on CircleCI!
Details
ci/circleci: Group 6 Your tests passed on CircleCI!
Details
ci/circleci: Group 7 Your tests passed on CircleCI!
Details
ci/circleci: Group 8 Your tests passed on CircleCI!
Details
ci/circleci: Group 9 Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@Floriferous

This comment has been minimized.

Floriferous commented Sep 23, 2018

Does this mean it is only supported on meteor server side? I'm getting this error on MS Edge:Object doesn't support property or method 'finally'.

Even when using babel, I have to add a a polyfill for this to work everywhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment