The type of the event payload.
The type of the event.
Returns the AbortSignal for this PubSub instance. Use this signal with APIs that support cancellation (fetch, addEventListener, etc.) When the PubSub is destroyed, the signal will be aborted and all listeners using it will be automatically removed.
Unsubscribe a function previously subscribed with on
An event name to which the provided function was previously subscribed.
A function that was previously passed to on. The function must have the same reference as the function that was subscribed.
Subscribe a function to an event.
An event name which, when fired, will call the provided function.
A callback that gets called when the corresponding event is fired. The callback will get passed an argument with a type that's one of event payloads.
Optionaloptions: { signal?: AbortSignal }Optional options object. If a signal is provided, the subscription will be automatically cleaned up when that signal is aborted.
A cleanup function that unsubscribes the event listener when called.
Subscribe a function to be called when the signal is aborted.
The function to call when the signal is aborted.
Generic PubSub class implementing the Publish-Subscribe pattern for event handling.