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

2.0 #12

Merged
merged 29 commits into from
Dec 10, 2013
Merged

2.0 #12

merged 29 commits into from
Dec 10, 2013

Conversation

jsor
Copy link
Member

@jsor jsor commented Oct 22, 2013

The goal is to streamline the API and to make it more compliant with other promise libraries and especially with the new upcoming ES6 promises specification.

  • Add standalone Promise class.
    Provides an alternative promise-creation API that has the same power as the deferred concept, but without introducing another conceptual entity plus it's identical with the Promise object from the upcoming ES6 promises specification.
  • Add new React\Promise\race() function.
    Initiates a competitive race that allows one winner. Returns a promise which is resolved in the same way the first settled promise resolves (See also ES6 spec).
  • BC break: Bump minimum PHP version to PHP 5.4.
    Allows the callable typehint (see a4d6358, removes the hacky error triggering from a0f23cb). $this can be used in anonymous functions (example).
  • BC break: Remove ResolverInterface and PromiseInterface from Deferred.
    Usage of Deferred::then has been always discouraged and it only existed because it was used by the (now removed) DeferredPromise class. Removed the ResolverInterface entirely for the sake of simplicity. I haven't come across any single userland usage.
  • BC break: Change signature of PromiseInterface.
    Added the callable typehint and renamed arguments to be compliant with the ES6 promises specification and Promise/A+ naming conventions.
  • BC break: Remove When and Util classes and move static methods to functions.
    FFTW (Functions For The Win).
  • BC break: FulfilledPromise and RejectedPromise now throw an exception when initialized with a promise instead of a value/reason.
    This is more a bugfix than a BC break. Since FulfilledPromise and RejectedPromise are now documented in the API docs, i fixed it. In 1.0, we only documented When::resolve() and When::reject() as public API which only creates instances if value/reason was not a promise.
  • BC break: React\Promise\Deferred::resolve() and React\Promise\Deferred::reject() no longer return a promise.

$resolver,
function ($value = null) {
return $this->resolve($value);
},
Copy link
Contributor

Choose a reason for hiding this comment

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

can just be [$this, 'resolve']

Copy link
Member Author

Choose a reason for hiding this comment

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

No, because resolve is private. The closure is needed for the class scope.

Copy link
Contributor

Choose a reason for hiding this comment

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

gotcha!

$resolver(
function ($value = null) {
$this->resolve($value);
},
Copy link
Contributor

Choose a reason for hiding this comment

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

could this be simply [$this, 'resolve']?

Copy link
Member Author

Choose a reason for hiding this comment

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

See #12 (comment) :)

Copy link
Contributor

Choose a reason for hiding this comment

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

LOL again? :) /me slaps himself...

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.

2 participants