-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Conversation
Also removes trigger_error's for non-function arguments and related tests
$resolver, | ||
function ($value = null) { | ||
return $this->resolve($value); | ||
}, |
There was a problem hiding this comment.
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']
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); | ||
}, |
There was a problem hiding this comment.
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']
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #12 (comment) :)
There was a problem hiding this comment.
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...
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.
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.
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).
Allows the callable typehint (see a4d6358, removes the hacky error triggering from a0f23cb).
$this
can be used in anonymous functions (example).Usage of
Deferred::then
has been always discouraged and it only existed because it was used by the (now removed)DeferredPromise
class. Removed theResolverInterface
entirely for the sake of simplicity. I haven't come across any single userland usage.Added the callable typehint and renamed arguments to be compliant with the ES6 promises specification and Promise/A+ naming conventions.
FFTW (Functions For The Win).
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()
andWhen::reject()
as public API which only creates instances if value/reason was not a promise.