/// /// export type SignalParams = Parameters never : T extends unknown ? (arg: T) => never : () => never>; export type SignalCallback = (...args: SignalParams) => unknown; export type SignalWait = T extends unknown[] ? LuaTuple : T; /** * Represents a connection to a signal. */ export declare class Connection { private signal; /** * Whether or not the connection is connected. * @readonly */ Connected: boolean; /** * @hidden */ _next?: Connection; /** * @hidden */ _fn: SignalCallback; constructor(signal: Signal, /** @hidden */ fn: SignalCallback); /** * Disconnects the connection. */ Disconnect(): void; /** * Alias for `Disconnect`. */ Destroy(): void; } /** * Signals allow events to be dispatched to any number of listeners. */ export declare class Signal { private waitingThreads; /** * @hidden */ _handlerListHead?: Connection; /** * Connects a callback. This callback will be fired when the signal * is fired and will receive the arguments passed through firing. * @param callback `SignalCallback` * @returns `Connection` */ Connect(callback: SignalCallback): Connection; /** * Connects a callback, which will be disconnected after the next time * the signal is fired. * @param callback `SignalCallback` * @returns `Connection` */ Once(callback: SignalCallback): Connection; /** * Fires the signal. The passed arguments will be sent along to all * connected callbacks. Callbacks are invoked using `task.spawn` * internally. * @param args */ Fire(...args: SignalParams): void; /** * Fires the signal. The passed arguments will be sent along to all * connected callbacks. Callbacks are invoked using `task.defer` * internally. * @param args */ FireDeferred(...args: SignalParams): void; /** * Yields the current thread until the next time the signal is fired. * The arguments from firing are returned. * @yields * @returns `SignalWait` */ Wait(): SignalWait; /** * Disconnects all connections on the signal. */ DisconnectAll(): void; /** * Alias for `DisconnectAll`. */ Destroy(): void; }