@exmg/livery
Version:
Ex Machina Group Livery Web SDK.
70 lines (69 loc) • 2.83 kB
TypeScript
import { Disposable } from './Disposable';
/**
* A Disposable class that facilitates working with a list of Disposables (e.g: children).
*/
export declare class DisposableContainer implements Disposable {
disposed: boolean;
private disposables;
/**
* @param disposables Disposables to add to this container
*/
constructor(disposables?: Disposable[]);
/**
* Adds a Disposable to this DisposableContainer.
*
* @param disposable Disposable to add to this container
* @returns Wrapped Disposable disposing specified Disposable and removing itself from this DisposableContainer.
*/
addDisposable(disposable: Disposable): {
dispose: () => void;
};
/**
* Adds a Disposable interval callback.
*
* @param callback Function to call every delay
* @param delay Delay in milliseconds
* @param args Arguments to pass through to the function
* @returns Disposable clearing this interval and removing itself from this DisposableContainer.
*/
addDisposableInterval(callback: Parameters<typeof window.setInterval>[0], delay: Parameters<typeof window.setInterval>[1], ...args: unknown[]): {
dispose: () => void;
};
/**
* Adds a Disposable event listener to an event target.
*
* @param target Target to add event listener to
* @param type Event type to listen for
* @param listener Function to call when specified type occurs
* @param options Event listener options
* @returns Disposable removing this listener from the target and itself from this DisposableContainer.
*/
addDisposableListener<T extends Event>(target: EventTarget, type: string, listener: (event: T) => unknown, options?: boolean | AddEventListenerOptions): {
dispose: () => void;
};
/**
* Adds a Disposable timeout callback.
*
* @param callback Function to call after delay
* @param delay Delay in milliseconds
* @param args Arguments to pass through to the function
* @returns Disposable clearing this timeout and removing itself from this DisposableContainer.
*/
addDisposableTimeout(callback: Parameters<typeof window.setTimeout>[0], delay: Parameters<typeof window.setTimeout>[1], ...args: unknown[]): {
dispose: () => void;
};
/**
* Adds a dispose callback to this DisposableContainer.
*
* @param dispose Dispose callback
* @returns Wrapped Disposable using specified dispose callback and removing itself from this DisposableContainer.
*/
addDispose(dispose: () => void): {
dispose: () => void;
};
/**
* Disposes this DisposableContainer's disposables in reverse order.
* Overrides all property values by undefined and methods by ones that throw.
*/
dispose(): void;
}