EventManager

class EventManager(screenId: String, eventRunnerManager: EventRunnerManager, koinScope: Scope)

Owns the running of one screen's event chains — the counterpart of TilesManager on the event side, one instance per screen. Given an EventTrigger to look up, or an EventSchema/list of them to run directly, it builds a fresh EventRunningScope wired to that screen's collaborators and dispatches to the matching dev.catbit.mosaic.client.ui.sdui.foundation.events.EventRunner via eventRunnerManager.

EventManager and TilesManager are constructed together for a screen but depend on each other (an event needs to edit the tile tree; a tile's local interaction needs to run events) — that circular dependency is resolved by constructing EventManager with only screenId, eventRunnerManager and koinScope up front, then wiring in the TilesManager-provided collaborators immediately after via attachTilesEditor/attachTilesOverlaysEditor/ attachTilesEventHolder/attachTilesEventDispatcher/attachTilesValueProducer, plus attachScreenBehaviors/attachDataHolder for the screen-level ones. Every runEvent call is expected to happen only after all of these have been attached.

Parameters

screenId

id of the screen this manager runs events for — forwarded as EventRunningScope.screenId on every run.

eventRunnerManager
koinScope

the Koin scope every built EventRunningScope resolves dependencies from, and that runEvent itself uses to reach a MosaicLogger for its own top-level error handling.

Constructors

Link copied to clipboard
constructor(screenId: String, eventRunnerManager: EventRunnerManager, koinScope: Scope)

Functions

Link copied to clipboard
fun attachDataHolder(screenDataHolder: ScreenDataHolder)

Wires in the ScreenDataHolder every subsequently-run event's EventRunningScope exposes as screenDataHolder.

Link copied to clipboard
fun attachScreenBehaviors(screenBehaviorsHolder: ScreenBehaviorsHolder)

Wires in the ScreenBehaviorsHolder every subsequently-run event's EventRunningScope exposes as screenBehaviorsHolder.

Link copied to clipboard
fun attachTilesEditor(tilesEditor: TilesEditor)

Wires in the TilesEditor every subsequently-run event's EventRunningScope exposes as tilesEditor. Must be called (typically right after construction, by the screen's TilesManager) before runEvent is used.

Link copied to clipboard

Wires in the TilesEventDispatcher every subsequently-run event's EventRunningScope exposes as tilesEventDispatcher.

Link copied to clipboard

Wires in the TilesEventHolder uses to look up which registered events match a given trigger.

Link copied to clipboard

Wires in the TilesOverlaysEditor every subsequently-run event's EventRunningScope exposes as tilesOverlaysEditor.

Link copied to clipboard

Wires in the TilesValueProducer every subsequently-run event's EventRunningScope exposes as tilesValueProducer.

Link copied to clipboard
suspend fun runEvent(eventSchema: EventSchema, data: Any? = null)

Builds a fresh EventRunningScope for eventSchema — wired to this manager's own screenId, koinScope, and every collaborator attached via the attach* methods above, plus this EventManager itself (so the scope's own onTrigger/runEventInline/runEventsInline can recurse back through runEvent) — and dispatches to the dev.catbit.mosaic.client.ui.sdui.foundation.events.EventRunner registered for eventSchema's concrete class, via eventRunnerManager.

Link copied to clipboard
suspend fun runEvents(eventSchemas: List<EventSchema>, data: Any? = null)

Runs every entry in eventSchemas in order via runEvent — used when a caller already has the exact list of events to run and doesn't need triggerEvents' trigger lookup.

Link copied to clipboard
suspend fun triggerEvents(trigger: EventTrigger, data: Any? = null)

Looks up every currently-registered EventSchema on this screen whose trigger equals trigger (via tilesEventHolder) and runs each one — the entry point for a screen-level trigger like onDisplay(), which isn't tied to a single tile's own events list the way dev.catbit.mosaic.client.ui.sdui.foundation.tiles.renderer.TileRenderingScope.triggerEvent is.