Skip to content

Add a disposer keyword for disposal methods #1459

Open
@dead-claudia

Description

@dead-claudia

What problem are you trying to solve?

https://github.com/tc39/proposal-explicit-resource-management is stage 3, with at least V8 starting to ship. Standards should be able to integrate with that with their existing disposer methods.

What solutions exist today?

Many standards have methods like .close(), .abort(), and so on.

How would you solve it?

Add a disposer keyword that interfaces can use to alias a method to Symbol.dispose, and a similar async_disposer for Symbol.asyncDispose.

  • All parameters must be optional.
  • async_disposers must return promises.

For a few examples:

[Exposed=(Window,Worker)]
interface WebSocket : EventTarget {
  // ...
  disposer undefined close(optional [Clamp] unsigned short code, optional USVString reason);
  // ...
};

interface mixin ReadableStreamGenericReader {
  readonly attribute Promise<undefined> closed;

  async_disposer Promise<undefined> cancel(optional any reason);
};

[Exposed=(Window,Worker)]
interface IDBTransaction : EventTarget {
  // ...
  undefined commit();
  disposer undefined abort();
  // ...
};

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions