Skip to content

Conversation

@andrewimm
Copy link
Contributor

Allows Parse.Promises to be constructed in the ES6 "executor" style, without intervening with old construction.

// Valid:
return new Parse.Promise((resolve, reject) => {
  myAsyncFunction((result) => {
    resolve(result);
  });
});

// Also still valid:
let p = new Parse.Promise();
myAsyncFunction((result) => {
  p.resolve(result);
});
return p;

cc @grantland

@andrewimm
Copy link
Contributor Author

Part of the launch checklist for #136

@andrewimm
Copy link
Contributor Author

Also added the following static constructors from the ES6 spec:

Parse.Promise.resolve(value);
Parse.Promise.resolve(thenable); // Chains the new promise to the end of the old one, essentially a noop
Parse.Promise.reject(error);

Copy link
Contributor

Choose a reason for hiding this comment

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

can we use executor as param name for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 absolutely. I was calling it "closure" before I read the spec and determined it was deemed an "executor"

@peterdotjs
Copy link
Contributor

LGTM.

peterdotjs added a commit that referenced this pull request Jan 5, 2016
@peterdotjs peterdotjs merged commit 5e5c444 into release-1.7.0 Jan 5, 2016
@andrewimm andrewimm deleted the andrewi.promise_constructor branch January 5, 2016 19:10
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

Successfully merging this pull request may close these issues.

4 participants