dispatch_event

Function dispatch_event 

Source
async fn dispatch_event(
    event: Event,
    wstore: Arc<WaveStore>,
    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 service.rs RPC handlers, apply_event_to_wstore is called synchronously (service.rs:1297-1304 for workspace; equivalent path for tab/block/window/layout commands) before publish_events (service.rs:1305). 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:295 dispatches reducer events directly without first calling apply_event_to_wstore; 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 wstore.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.