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

Struggling with the await syntax #72

Closed
RobbyDmz opened this issue Nov 14, 2017 · 3 comments
Closed

Struggling with the await syntax #72

RobbyDmz opened this issue Nov 14, 2017 · 3 comments

Comments

@RobbyDmz
Copy link

RobbyDmz commented Nov 14, 2017

I'm wondering what the reason is behind this syntax:

const userAge = userId |> fetchUserById |> await |> getAgeFromUser

I would expect the piping syntax to either implicitly handle awaitable code:

const userAge = userId |> fetchUserById |> getAgeFromUser

Or explicitly but with this cleaner variant:

const userAge = userId |> await fetchUserById |> getAgeFromUser

The current proposal confuses me. Can you make a comment on the reason behind it? Or on the alternatives I suggested?

@mAAdhaTTah
Copy link
Collaborator

See #66. Short version is the second variant isn't clear whether it's awaiting the value fetchUserById or the result of the function call.

@littledan
Copy link
Member

We might want to switch to the second one; discussion is ongoing. For the first one, so far TC39 is hesitant about adding awaits implicitly, as it has rather big implications for synchronicity--each await queues you on the microtask queue, which is like giving up a big lock.

@RobbyDmz
Copy link
Author

Thanks for the quick responses.
I agree that the first one has a big impact but that was just my 'reflex response'.
Good to see this discussion is ongoing.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants