Skip to content

Commit

Permalink
Large rewrite of internals to satisfy subclassing constraints.
Browse files Browse the repository at this point in the history
This rewrite was the result of many discussions, starting in #54, but continuing into countless IM and email conversations. There were several competing concerns that arose, and I think this satisfies them all.

This rewrite is inspired largely by @rossberg-chromium's https://github.com/rossberg-chromium/js-promise/blob/master/promise.js, although there were many modifications necessary to make it work and pass all the tests.

In the end, the guiding principles seem to be:

- Store resolution value and rejection reason, instead of trying to extract a fulfillment value from the resolution value.
- Centralize all unwrapping in `then`, both on the input side (done by Promise Resolution Handler Functions) and the output side (done by Promise Reaction Functions).
- Do not differentiate between promises, promise subclasses, and thenables; use the `then` interface to send messages to all of them.
- More generally, do not use abstract operations when methods will do. Abstract operations should only supply the default implementation of methods.

As part of this rewrite, several other issues were addressed; #36 was started on, and most editorial and formatting issues (#34, #37, #49) were taken care of. This also closes #60 by virtue of that function no longer existing.

Note that the thenable coercions weak map was temporarily removed; it will be added back later (#39 #61).
  • Loading branch information
domenic committed Oct 28, 2013
1 parent 7e845e4 commit 002ec7a
Show file tree
Hide file tree
Showing 4 changed files with 369 additions and 523 deletions.
Loading

3 comments on commit 002ec7a

@rossberg
Copy link

@rossberg rossberg commented on 002ec7a Oct 29, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domenic
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rossberg-chromium Would you mind opening separate issues for those so we can discuss them separately? I guess the first two can be lumped together.

@rossberg
Copy link

@rossberg rossberg commented on 002ec7a Oct 31, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.