跳至主要內容

异步显式资源管理

小于 1 分钟featurees-proposalmissing-example

异步显式资源管理open in new window

只包含提案中内建的,using 语法需要转译支持。

模块

类型

interface SymbolConstructor {
  readonly asyncDispose: unique symbol;
}
class AsyncDisposableStack {
  constructor();
  disposeAsync(): Promise<void>;
  use<T = AsyncDisposable | Disposable>(value: T): T;
  adopt<T>(value: T, onDispose: (value: T) => void | Promise<void>): T;
  defer(onDispose: Function): void;
  [Symbol.asyncDispose](): Promise<void>;
  [Symbol.toStringTag]: "AsyncDisposableStack";
}
interface AsyncDisposable {
  [Symbol.asyncDispose](): Promise<void>;
}

入口点

core-js/proposals/async-explicit-resource-management
core-js(-pure)/full/symbol/async-dispose
core-js(-pure)/full/async-disposable-stack
core-js(-pure)/full/async-iterator/async-dispose