///
///
interface EventListener {
(evt: Event): void;
}
interface EventListenerObject {
handleEvent(object: Event): void;
}
interface EventListenerOptions {
capture?: boolean;
}
interface AddEventListenerOptions extends EventListenerOptions {
/** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
once?: boolean;
/** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
passive?: boolean;
}
/** Function to remove an event listener. */
export type RemoveEventListener = () => void;
/** Extended AbortSignal with subscription management. */
export interface CancelableAbortSignal extends AbortSignal {
__is_cancelable_abort_signal: true;
/**
* Subscribe to signal events with automatic cleanup support.
* @param listener - The event listener callback
* @param options - Event listener options
* @returns Function to remove this specific listener
*/
subscribe(listener: EventListener | EventListenerObject, options?: AddEventListenerOptions | boolean): RemoveEventListener;
/**
* Subscribe to a specific event type on the signal.
* @param type - The event type to listen for
* @param listener - The event listener callback
* @param options - Event listener options
* @returns Function to remove this specific listener
*/
subscribe(type: string, listener: EventListener | EventListenerObject, options?: AddEventListenerOptions | boolean): RemoveEventListener;
}
/**
* Enhanced AbortController with subscription management.
*
* @example
* ```ts
* const controller = new CancelableAbortController();
* const unsub = controller.signal.subscribe(() => console.log('Aborted'));
* controller.abort(); // Cleanup all listeners
* ```
*/
export declare class CancelableAbortController extends AbortController {
private _subscriptions;
/**
* Get all active subscription cleanup functions.
*/
get subscriptions(): RemoveEventListener[];
signal: CancelableAbortSignal;
constructor();
/**
* Abort the signal and cleanup all subscriptions.
*/
abort(): void;
/**
* Remove all event listeners and cleanup subscriptions.
*/
dispose(): void;
}
export default CancelableAbortController;