You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a class implements AsyncDisposable, it can be used with using. It automatically disposes the resource if the scope exits, even if there was an exception:
// container class implemeting:classFooContainerextendsGenericContainerimplementsAsyncDisposable{[Symbol.asyncDispose](): PromiseLike<void>{this.stop();}}// usage:awaitusingcontainer=newFooContainer().start();// ... testing ...// oopsie, an exception was thrown// ...// container.asyncDispose() will be called regardless// no dangling container left behind
If the user doesn't use await using, everything behaves like it always had. So this wouldn't be a breaking change, just
offering the ability to guarantee stopping the container.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
AsyncDisposableis a new interface defined like that:If a class implements AsyncDisposable, it can be used with
using. It automatically disposes the resource if the scope exits, even if there was an exception:If the user doesn't use
await using, everything behaves like it always had. So this wouldn't be a breaking change, justoffering the ability to guarantee stopping the container.
TC39 spec, TS support
All reactions