Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

@@asyncDispose motivation/use cases #4

Open
@littledan

Description

@littledan

I'd like to understand better the motivation for adding @@asyncDispose and AsyncDisposalStack now, in this proposal, as opposed to focusing on just launching disposal and not waiting on it. Apologies, I haven't caught up on all the threads where this has been discussed; feel free to point me to a past explanation if one is already written.

Your section on how web APIs would integrate with disposal is really interesting and provides good motivation, but not to the point where I fully understand the design. It's notable that these examples include a method .close() both in cases that return undefined and cases that return a Promise. I'm wondering, would this be a reasonable pattern to follow for @@dispose, allowing it to return a Promise, rather than using a separate symbol?

In this case, the only difference between using x = y and using (await x = y) { } would be whether we bother waiting on the value returned from @@dispose--in the former case, we're fine to let disposal happen in the background, but the same thing executes. Similarly, for AsyncDisposableStack, the difference would be whether we block on starting one disposal for the next one, or just launch them all in parallel (and maybe this would be a an option to the constructor rather than a separate class).

I'm asking this partly because I'm having trouble understanding when it is important to block control flow on the disposal completing, as opposed to being content having launched it off in the background. Presumably these use cases went into the design of the referenced web APIs, but I don't know where to find more information about that.

(A way to avoid coming to a conclusion on this question would be to just skip @@asyncDispose and AsyncDisposalStack for now and introduce them later, but given the pattern's usage in the web platform, I can sympathize with the impulse for adding it now.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions