docs
Systems
Messaging
SignalSystem
Key Components

Overview

SignalSystem has no manager or coordinator classes. Its parts are a catalog of keys, a name builder, a key type, and a message type. The signal bus that uses them is in the BusSystem.

SaffronLibrarySignals (signal catalog)

The shared catalog of signal keys. It holds SceneReady, SystemsReady, and DataSystemReady.

Systems use these fields in two ways:

  • To raise a signal: wrap the key in a Signal and pass it to BusUtility.Raise.
  • To wait for a signal: pass the key to the signal bus's waiting method, which runs the callback immediately if the signal was already raised.

New shared signals should be added here, as static readonly fields, so that every system refers to the same key.

SignalKeyNames (name builder)

Builds the string names behind the catalog keys from a shared base (core.signal) and segments. The names are constants. Use this class to keep names consistent when adding new signals. Do not use these strings directly in other code; use the keys from SaffronLibrarySignals.

SignalKey (identity)

The key type used by everything in the signal flow.

  • The signal bus uses it as the routing key, so listeners wait for one specific signal.
  • The base message bus uses it to gate a routing key on a ready signal.
  • Its equality is by name, so separately constructed keys with the same name match.

Signal (message)

The message delivered when a signal is raised. It carries the SignalKey and nothing else. Create it with the key:

BusUtility.Raise(new Signal(SaffronLibrarySignals.SystemsReady));

ISignalKey (contract)

The interface SignalKey implements. It exposes the Id string. Code that needs only the identifier can depend on this interface rather than on the struct.

Listeners and handlers

This folder defines no handler or listener interfaces. A listener is a callback passed to the signal bus's waiting method. The signal bus stores it under the signal's key, runs it when the signal is raised, and then removes it. The bus is documented in the BusSystem.

Interaction with BusSystem classes

  • SignalBus: Stores the raised state and the listeners for each key. It takes SignalKey as its routing key and Signal as its message type.
  • BusUtility: The entry point for raising a Signal.
  • MessageBus: Uses SignalKey values to gate other routing keys on ready signals.
  • BusRegistry: Holds the SignalBus instance, which callers reach through ServiceLocator.

Use the catalog keys with these classes. Do not create keys from raw strings unless you are adding a new entry to the catalog.