ReferenceAsk
Remy Reference/interface/EventsSubscription
?

EventsSubscription

Type
The handle events.connect returns: close the stream, read its connection state, and publish ephemeral client events.

What events.connect hands back. close() stops the stream and all reconnection, and is safe to call more than once, so it's the natural thing to run on unmount. state reports whether the subscription is connecting, open, or closed. publish sends ephemeral events straight from the browser on channels the grant allows, the fast path for cursors, typing, and live strokes. It's fire-and-forget, coalesced, at-most-once, and capped at 8k: signals only, while durable state still commits through a method.

EventsSubscription.ts
interface EventsSubscription {
  close(): void
  readonly state: 'connecting' | 'open' | 'closed'
  publish(channels, data): void
}
Fields
close
() => void
Stops the stream and all reconnection. Idempotent, so it is safe to call on unmount and again.
state
'connecting' | 'open' | 'closed'
ReadonlyThe current connection state.
publish
(channels: string | string[], data: unknown) => void
Publish an ephemeral event on channels the grant carries publish capability for. The client-direct fast path, with no backend method per signal: right for cursors, typing indicators, and live stroke batches. Fire-and-forget and coalesced to roughly 40ms flushes, so calling it per input event is fine; delivery is at-most-once and nothing is retried, and payloads cap at 8k. Put a client seq in the payload if receivers need cross-batch ordering, and commit durable state through a method.
Close when the view unmounts
const sub = events.connect({ /* ... */ });
return () => sub.close(); // e.g. a React effect cleanup