-
-
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
Merge promise interfaces #75
Conversation
Merge PromiseInterface, ExtendedPromiseInterface and CancellablePromiseInterface into a single PromiseInterface. The CancellablePromiseInterface is kept for backward compatibility but is marked as deprecated and must not be used anymore. Closes #44
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.
So much 👍 on this, type hinting is a P.I.T.A. if you want to be compatible and ensure the promise can be canceled
I mostly kept |
Are you sure merging |
@kelunik All promises have a |
@jsor Might make sense then as long as |
I'm not sure i understand what that has to do with the interface merge? The interfaces are only separate for backward compatibility reasons because they were introduced separately. All promise implementations in react/promise implement all 3 interfaces. |
Ah, fine then. I thought cancelability was an optional thing before. |
I've now also removed When supporting react/promise if ($promise instanceof CancellablePromiseInterface) {
$promise->cancel();
} A possible solution is to pass React\Promise\resolve($promise)->cancel(); Please note, that this adds some overhead if Another solution would be to just test against if ($promise instanceof PromiseInterface) {
$promise->cancel();
} All promise implementations from react/promise < 3.0 implement both This would break though, when The safest solution would probably be a combination of the two methods: if ($promise instanceof PromiseInterface) {
React\Promise\resolve($promise)->cancel();
} |
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.
Nice! The changes make perfect sense and the upgrade guide is much appreciated! 👍
Merge
PromiseInterface
,ExtendedPromiseInterface
andCancellablePromiseInterface
into a single PromiseInterface.The(Edit: Also removed in 251b4e5)CancellablePromiseInterface
is kept for backward compatibility but is marked as deprecated and must not be used anymore.Closes #44