AbstractStaticsubscribeEventSignal
Callback function
Optionaloptions: EventCallbackOptionsOptional once flag
StaticsubscribeSubscribe to a given event, automatically unsubscribing after first execution.
Optionaloptions: EventCallbackOptionsStaticunsubscribeUnsubscribe a callback from an event.
StaticemitStaticsubscribeSubscribe to a custom event (internal event system).
The name of the custom event to listen for.
The callback to run when the event is emitted.
Optionaloptions: { once?: boolean }Supports once to auto-unsubscribe after the first trigger.
EventUtil.subscribeCustom("onNewDay", (data) => {
console.log(`Day ${data.currentDay} has started!`);
});
Use EventUtil.subscribe with an EventSignal instead
StaticsubscribeUse EventUtil.subscribeOnce with an EventSignal instead
StaticunsubscribeUse EventUtil.unsubscribe with an EventSignal instead
StaticemitEmit (trigger) a custom event.
You can pass either:
this), and all its properties and methods will be collected
and passed as the event data.The custom event name.
OptionaldataOrEmitter: anyAn object with event data, or an instance whose properties will be collected.
// Emit with plain data
EventUtil.emitCustom("onNewDay", { day: 5 });
// Emit with all properties/methods of a class instance
EventUtil.emitCustom("onNewDay", this);
Use EventUtil.emit with an EventSignal instead
Subscribe to a given event.