-
Notifications
You must be signed in to change notification settings - Fork 3
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
Require sync "when" invocations after resolution #26
Conversation
It specifies the exact invocation parameter values now and includes a statement about always-sync when callbacks. Closes #20.
Does this mean the following needs to be removed from the spec?
I'm thinking about what should happen if a promise has just been resolved and is in the process of firing it's callbacks (or has deferred doing so) when |
@joshdifabio no, that should still take priority. EDIT: looks like I was misunderstanding you… |
Even though amp doesn't currently satisfy this requirement?
Is it clear what I mean? |
Here's a code example. function ($promise) {
$promise->when(function () use ($promise) {
echo '1';
$promise->when(function () {
echo '3';
});
});
$promise->when(function () {
echo '2';
});
$promise->resolve('foo');
} I think this would print 132 in Amp, even though according to the spec it should print 123? Always-sync |
@joshdifabio Amp will soon be fixed, I wasn't aware of that. |
On the other hand, we might just drop that requirement, dunno whether it's important. |
I think the existing requirement regarding the invocation order of callbacks is much more important than the one added in this PR, and while it's probably not that hard to support both requirements in Amp it would be extremely difficult for libs with task queues which are deferring invocation to do so. |
@joshdifabio If we merge this PR, then there MUST NOT be any task queues. This PR exist to eliminate them. |
Aha! I hadn't realised. |
I just made the title of this PR clear. It does way more than it actually should. The clarification should be on a separate PR. |
@jsor Are you fine with that? 10 hours ago you said you'd prefer unspecified, but then you said a always sync implementation is possible in React. |
I just want to clarify; are you saying that React and others would have to completely remove their task queues? (I believe that they would, unless we stop requiring that callbacks are fired in a particular order.) |
They can do what they want. Just not for |
I'm not sure, but due to this being a little ambiguous in the text, could you please just specify a bit more precisely when what is called (immediate vs. queue). |
As per amphp/amp#57, the following two requirements are mutually exclusive:
So this PR needs to also remove or modify the second clause. |
Callbacks can't be executed always-sync and in the same order as registered in the edge case where another when handler is registered within a when handler. Once a promise is resolved, all new when handlers must be executed immediately now.
I just adjusted the PR. |
Now it's unambiguous :-) |
Looks good. Thanks @kelunik! |
I'd like to await @jsor's approval for this PR. |
It specifies the exact invocation parameter values now and includes a statement about always-sync when callbacks.
Closes #20.