Skip to content

Closing an asynchronous generator #10

@mnieper

Description

@mnieper

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions