Optional debug name, reported by the default Signal.errorHandler when a listener throws.
ReadonlynameOptional name, for debugging / error reporting.
StaticerrorCalled when a listener throws during emit. Replace to route
listener errors elsewhere (or rethrow to make failures fatal, e.g. in
tests). The default logs via console.error and continues, so one broken
listener cannot starve the others.
True if at least one listener is connected. Emitters can use this to skip building expensive emit arguments nobody will receive.
Number of connected listeners.
StatichasTrue if any queueEmit is waiting to be flushed.
Connect a listener. Connecting the same function twice is a no-op (it will still be invoked once per emit).
Callback invoked with the emit arguments. For an object method
pass a bound function or arrow wrapper (() => this.onDied()).
Optionalopts: SignalConnectOptionsSee SignalConnectOptions.
An unsubscribe function; calling it disconnects fn (idempotent).
connect with once: true — the listener auto-disconnects after
its first invocation.
Disconnect every listener.
Invoke every connected listener with args, synchronously and in
connection order. See the class doc for reentrancy and error semantics.
Defer an emit until Signal.flushQueued — the engine flushes once
per frame right after scene.update, so listeners run at a safe point
where mutating the scene is allowed. Multiple queued emits (of any signal)
run in queue order. Arguments are captured by reference at queue time.
Outside an engine loop (unit tests, workers) call Signal.flushQueued yourself.
StaticflushRun every pending queueEmit, including emits queued by the
listeners themselves, until the queue is empty. The engine calls this once
per frame after the simulation step. Guards against unbounded
queue-from-flush loops by bailing out (with a console.error) after
processing 10,000 entries in one flush.
A typed, multi-listener event bound to an object property. Being a property rather than a string-keyed event makes the set of events a class emits explicit, removes misspelled-name bugs, and lets TypeScript check listener argument types end-to-end:
connectreturns an unsubscribe function; components should prefer Component.listen, which disconnects automatically when the component detaches.Emit semantics:
console.error).