Add integration with new async/await support in 2.12.12+ and 2.13.3+ #279
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Currently, the primary syntax to compose Twitter futures is using
map/flatMap
syntax. This syntax may feel verbose and unfamiliar to developers who have worked with other languages such as JavaScript or C# that support async/await.Solution
This PR adds async/await support for
com.twitter.util.Future
. This functionality isonly available in the newly released 2.13.3 (notes https://github.com/scala/scala/releases/tag/v2.13.3). It will also become available in the upcoming 2.12.12 release.
Result
Users can write code like this now
The equivalent way to to write the same code above with the current syntax is
Notes
The code in this PR is adapted from the code in scala/scala-async#237
To try out this PR locally run the following commands