Skip to main content

dispatch_event

Function dispatch_event 

Source
async fn dispatch_event(
    event: Event,
    mstore: Arc<Store>,
    event_bus: Arc<EventBus>,
)
Expand description

Translate one reducer event into zero or more waveobj:update broadcasts.

Read source — post-event state guarantee: For events emitted via the HTTP server/service RPC handlers, apply_event_to_mstore is called synchronously (workspace_lifecycle.rs’s handle_update_workspace for workspace; equivalent path for tab/block/window/layout commands) before publish_events (reducer_helpers.rs). So when the bridge receives such an event, SQLite is already up-to-date.

IPC-path caveat: the launcher → IPC path in srv_ipc/server.rs’s handle_connection dispatches reducer events directly without first calling apply_event_to_mstore; the persist subscriber and bridge then race. At time of writing none of the events the bridge handles are emitted via that path (verified for Command::UpdateWindowMeta and the workspace family). When that changes, options are: (a) make the IPC path apply synchronously like HTTP does, or (b) read from the in-memory srv_state reducer rather than SQLite. Tracked in SPEC_OBJ_UPDATE_BRIDGE §11.1.

Lock discipline (per ReAgent P1 on PR #852): every mstore.get<T>() is wrapped in tokio::task::spawn_blocking via the helpers above so the async runtime stays responsive even under reducer-transaction contention.

Coverage: Phase 1 + 2 covers workspace, window, tab, block, layout events. Saga events, OS facts, launcher-domain events all fall through to the catch-all _ => {} arm.