-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Use async as a suffix rather than a prefix for asynchronous variants. #22134
Conversation
…of methods. This is better aligned with standard javascript convention. Often libraries have the default version be asynchronous, and name the Sync one explicitly, we are marking the async ones as they are by far the most common and usable for pipeline construction.
R: @pskevin |
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.
LGTM.
I was wondering if we should default to making all apply calls be Async (they would return some sort of Future) and we could have futures applied on futures... wdyt Robert? This is of course a big change to the API - I'm just spitballing... |
I did consider this, but it would make chaining much more verbose. E.g. instead of
one would have to write
or
which gets really painful. (Note that the future here is Javascript's Promise, which is a kind of special builtin). |
I thought of something like this:
Where each though I haven't researched JS enough, I think this is doable... |
To do this one would have to add methods like flatMap to the Promise prototype (affecting all Promises across Javascript) or return a subclass (well, really a hierarchy of subclasses) of Promise (which I looked into and looks pretty sketchy). This would work if Promise could be a proxy object to the type it was promising, but it's not. It looks like another alternative is
but this is still a bit icky, and looses type safety. |
Well thanks for doing the research and sharing your thoughts:)
…On Mon, Jul 11, 2022, 12:45 PM Robert Bradshaw ***@***.***> wrote:
To do this one would have to add methods like flatMap to the Promise
prototype (affecting all Promises across Javascript) or return a subclass
(well, really a hierarchy of subclasses) of Promise (which I looked into
and looks pretty sketchy). This would work if Promise could be a proxy
object to the type it was promising, but it's not.
It looks like another alternative is
lines
.invoke("map", (s: string) => s.toLowerCase())
.invoke("flatMap", function* splitWords(line: string) {
yield* line.split(/[^a-z]+/);
})
.invoke("apply", beam.countPerElement())
but this is still a bit icky, and looses type safety.
—
Reply to this email directly, view it on GitHub
<#22134 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJ5Z3FKBOP5NE5BJBACZBLVTR2WLANCNFSM52N5F5TA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
…apache#22134) This is better aligned with standard javascript convention. Often libraries have the default version be asynchronous, and name the Sync one explicitly, we are marking the async ones as they are by far the most common and usable for pipeline construction.
This is better aligned with standard javascript convention.
Often libraries have the default version be asynchronous, and
name the Sync one explicitly, we are marking the async ones as
they are by far the most common and usable for pipeline
construction.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username
).addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.