Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TheSerchCp/SEAM/llms.txt
Use this file to discover all available pages before exploring further.
EventBus is the central nervous system of SEAM’s front-end. It serves two roles simultaneously: an in-process publish/subscribe hub that decouples pages and components from one another, and a transparent bridge that forwards Socket.IO messages from the server into the same event stream. Any part of the application can listen for or emit events without holding a direct reference to the emitter.
Architecture Overview
Internal Pub/Sub
Pages, components, and repositories communicate by emitting named events. Listeners are stored in a
Map<string, Set<Function>> so multiple subscribers per event are supported natively.Socket.IO Bridge
When
connect(token) is called, EventBus establishes a Socket.IO connection and re-emits server-side events (operation:progress, data:changed) into the same internal bus. Pages subscribe with EventBus.on() and never interact with the socket directly.API Reference
on(event, cb)
Registers a listener for the given event name. Returns an unsubscribe function — calling it removes only this specific listener without affecting others on the same event.
The event name to subscribe to (e.g.
'data:changed', 'toast:success').Callback invoked with the event payload each time the event is emitted.
off(event, cb)
Removes a specific callback from an event’s listener set. Prefer the unsubscribe function returned by on() for brevity.
The event name.
The exact callback reference that was passed to
on().emit(event, payload)
Synchronously invokes all listeners registered for event, passing payload to each.
The event name to publish.
Arbitrary data forwarded to every listener.
clearEvent(event)
Removes all listeners for the given event at once. Useful for teardown scenarios where you want to reset an event channel entirely.
The event name whose entire listener set will be deleted.
connect(token)
Establishes a Socket.IO connection authenticated with the user’s JWT. Once connected, the socket events operation:progress and data:changed are bridged into the internal bus.
The JWT returned by
/auth/login. Used as { auth: { token } } in the Socket.IO handshake.API_BASE by stripping the /api/v1 suffix:
connect() guards against double-connections: if a socket is already open it is disconnected before the new one is created.disconnect()
Closes the Socket.IO connection, nullifies the internal _socket reference, and removes the global data:changed listener that was registered at connect time.
socketId (getter)
Returns the current Socket.IO socket ID, or null if not connected. ApiClient reads this value to set the X-Socket-ID request header so the server knows which tab initiated an operation.
Bridged Socket Events
These events originate on the server and are re-emitted verbatim into the internal bus by theconnect() bridge.
operation:progress
Sent only to the tab that initiated a long-running operation (targeted via X-Socket-ID). Used to drive loading spinners and progress messages.
data:changed
Broadcast to all connected clients when a mutation occurs on the server. Pages subscribe to this event and compare operation against their own interest list to decide whether to re-render.
Toast Events
These events are emitted byApiClient automatically on success and error, and may also be emitted manually anywhere in the application. The global Toast component (initialized in main.js) listens to all four.
| Event | When to use |
|---|---|
toast:success | Mutation completed successfully |
toast:error | HTTP error or network failure |
toast:warning | Non-fatal issue that needs attention |
toast:info | Neutral informational message |
Internal Events
page:reload
An internal signal that can be emitted to request the current page to re-initialize itself without a full route change. Individual pages may listen for this to refresh their data.
Full Internal Implementation
For reference, the complete bus internals use aMap of Sets — this means the same callback reference can only be registered once per event, preventing accidental duplicate subscriptions from multiple on() calls with the same function.