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

Add a disposer keyword for disposal methods #1459

Open
dead-claudia opened this issue Dec 22, 2024 · 0 comments
Open

Add a disposer keyword for disposal methods #1459

dead-claudia opened this issue Dec 22, 2024 · 0 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@dead-claudia
Copy link

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

@dead-claudia dead-claudia added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

1 participant