Initializes a new Callbacks
instance with an empty list of callbacks.
interface ICallbacks {
onAdd: undefined;
onDelete: undefined;
}
const callbacks = new Callbacks<ICallbacks>();
callbacks.add('onAdd', () => console.log('Callback for add'));
callbacks.add('onDelete', () => console.log('Callback for delete'));
callbacks.tbt('onAdd', undefined); // Trigger all "onAdd" callbacks
callbacks.tbt('onDelete', undefined); // Trigger all "onDelete" callbacks
Registers a new callback for a specific target event.
const callback = callbacks.add('onAdd', () => console.log('Callback added'));
callback.remove(); // Removes this specific callback
Triggers all callbacks associated with the specified target.
The target event name for which callbacks should be executed.
The argument to pass to each callback.
callbacks.tbt('onAdd', undefined); // Trigger all "onAdd" callbacks
Manages the registration and execution of callbacks for specific event types. Supports adding, removing, and triggering callbacks, with optional features such as protected callbacks, one-time execution, and execution delays.