Subscribe to real-time events from the Synapse session
The core SDK is event-driven. After starting a session, subscribe to events to receive streamed message chunks, tips, tool calls, and lifecycle signals. Drive your UI off these events.
import { SYNAPSE_REALTIME_EVENTS } from "@eka-care/medassist-core";function onChunk(evt) { appendToCurrentMessage(evt.data.text);}// Registersdk.on(SYNAPSE_REALTIME_EVENTS.MESSAGE_CHUNK, onChunk);// Remove (pass the same function reference)sdk.off(SYNAPSE_REALTIME_EVENTS.MESSAGE_CHUNK, onChunk);
off() requires the same function reference you passed to on(). Inline arrow functions can’t be removed — keep a reference if you need to unsubscribe.