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

Closing an asynchronous generator #10

Open
mnieper opened this issue Feb 2, 2015 · 0 comments
Open

Closing an asynchronous generator #10

mnieper opened this issue Feb 2, 2015 · 0 comments

Comments

@mnieper
Copy link

mnieper commented Feb 2, 2015

I currently trying to implement a working prototype for async generators on top of Traceur, and (at least) one issue has come up:

Consider the function that is given as an example, namely async function* getStockPrices(stockNames, nameServiceUrl). In the provided transcription into an asynchronous function, the code is full of checks if ($done) { this.return(); return; }. This is needed if we want the getStockPrices observable to return as soon as possible.

However, I wonder whether this is really what one wants: If I wrap several of the await expressions in getStockPrices in one async function, which is then called by getStockPrices there will be only one check whether I'm done or not, but not one for every await in the wrapping function. Thus we would lose transparency here (between wrapped and non-wrapped code).

Doesn't it make more sense to test for stopping just before the next yield that is going to happen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant