/** * A pattern for an object with a cleanup method called dispose(). * As designed, calling dispose() multiple times should not throw an error. * Later reuse of the disposable after calling dispose() is left up to the individual * implementation. */ export interface IDisposable { dispose(): void; } /** * A basic IDisposable implementation that wraps a cleanup method. */ export declare class Disposable implements IDisposable { protected cleanup: (() => void) | null; constructor(cleanup: () => void); /** * Performs the cleanup method - single use. Calling again will not perform cleanup again. */ dispose(): void; /** * An alias for dispose(). */ destroy(): void; } /** * Handles a group of IDisposable objects to be cleaned up at once. */ export declare class DisposableGroup extends Disposable { private group; constructor(...group: IDisposable[]); /** * Adds any number of disposable objects for later cleanup. */ add(...group: IDisposable[]): void; dispose(): void; /** Disposes the group, but then sets it back up to allow further uses of add() */ reset(): void; }