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

Add supporting for React/Promises v3 #351

Merged
merged 7 commits into from
Sep 15, 2023
Merged

Add supporting for React/Promises v3 #351

merged 7 commits into from
Sep 15, 2023

Conversation

roxblnfk
Copy link
Collaborator

@roxblnfk roxblnfk commented Sep 5, 2023

What was changed

Added supporting for react/promise v3 package.
I'm not sure that all 3rd packages was migrated to promises v3, that's why I paid attention to maintaining compatibility with the old promises version.

Why?

It adds new features of extended promises like methods catch(), finally() and cancel().
Also there were added @template annotations and better type coverage.

Checklist

  1. Closes [Maintenance] Update reactphp/promise to v3 #348
  2. All old tests passed
  • Implement Temporal\Promise functions that were deleted from react/promise v3

Release note

The ReactPHP Promise dependency has been updated from version 2 to version 3.

Note: there are no BC breaks in the Temporal SDK, but there are BC breaks in the ReactPHP Promise library.
If you rely on the functions of the ReactPHP Promise library and use them directly, please familiarize yourself with the list of changes there.
We have not completely abandoned compatibility with Promise v2, and it will be available for some time — just add "react/promise": "^2.9" in your composer.json, if you are tied to Promise v2.

Despite the fact that some functions (some(), map(), reduce()) have been removed from React, they have remained in our Temporal\Promise helper with the same behavior.

Otherwise, meet:

  • the new convenient methods of PromiseInterface: catch() and finally();
  • @template annotation for the PromiseInterface, which allows you to specify the type of the promise result.
    So start specifying types in Activity and Workflow, and when this initiative is implemented, the Workflow code will become fully typed and understandable for IDE and static analysis.
#[\Temporal\Activity]
class MyActivityClass {
    /**
     * @return PromiseInterface<non-empty-string>
     */
    #[\Temporal\ActivityMethod]
    public function myActivityMethod(): string {
        return 'some string';
    }
}

#[\Temporal\Workflow]
class MyWorkflowClass {
    #[\Temporal\WorkflowMethod]
    public function handle() {
        $activity = Workflow::newActivityStub(MyActivityClass::class);
        // IDE will know that the result is a string
        $result = yield $activity->myActivityMethod();
    }
}

@roxblnfk roxblnfk marked this pull request as ready for review September 15, 2023 11:59
@roxblnfk roxblnfk requested review from wolfy-j, Sushisource and msmakouz and removed request for wolfy-j September 15, 2023 11:59
@roxblnfk roxblnfk merged commit 3bbdb70 into master Sep 15, 2023
42 checks passed
@roxblnfk roxblnfk deleted the react-promise-3 branch September 15, 2023 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Maintenance] Update reactphp/promise to v3
3 participants