import { Collector } from "./Collector"; import { SignalConnection } from "./SignalConnection"; /** * Options for the connect method */ export type ConnectOptions = { /** Handlers with a higher order value will be called later. */ order?: number; /** Handlers with isPublic=false will not be removed when signal.disconnectAll is called. Disconnect manually or via SignalConnections */ isPublic?: boolean; }; /** * A signal is a way to publish and subscribe to events. * * @typeparam THandler The function signature to be implemented by handlers. */ export declare class Signal any> { private readonly head; private hasNewLinks; private emitDepth; private connectionsCount; /** * @returns The number of connections on this signal. */ getConnectionsCount(): number; /** * @returns true if this signal has connections. */ hasConnections(): boolean; /** * Subscribe to this signal. * * @param callback This callback will be run when emit() is called. * @param options Configure options for the connection */ connect(callback: THandler, { order, isPublic }?: ConnectOptions): SignalConnection; private onUnlink; /** * Unsubscribe from this signal with the original callback instance. * While you can use this method, the SignalConnection returned by connect() will not be updated! * * @param callback The callback you passed to connect(). */ disconnect(callback: THandler): boolean; /** * Disconnect all handlers from this signal event. */ disconnectAll(): void; /** * Publish this signal event (call all handlers). */ emit(...args: Parameters): void; protected emitCollecting(collector: Collector, args: Parameters): void; private unsetNewLink; }