Canvas Toolkit
← Class index

CSignal

Core

Type-safe signal that invokes connected slots when emitted. @typeParam TArgs Tuple containing the signal argument types.

import { CSignal } from "canvas-toolkit-lib";

Declared members

connect(slot: CSlot<TArgs>): () => void;

Connects a slot to the signal. @param slot Slot to invoke when the signal is emitted. @returns A function that disconnects the slot.

disconnect(slot: CSlot<TArgs>): void;

Disconnects a slot from the signal. @param slot Previously connected slot.

hasConnections(): boolean;

Returns whether the signal has connected slots.

emit(...args: TArgs): void;

Emits the signal and invokes all currently connected slots. @param args Arguments passed to each connected slot.