ReferenceAsk
Remy Reference/interface/EventsSubscription
?

EventsSubscription

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

What events.connect hands back. close() stops the stream and all reconnection and is safe to call more than once, so it is the natural thing to run on unmount. state reports whether the subscription is connecting, open, or closed.

EventsSubscription.ts
interface EventsSubscription {
  close(): void
  readonly state: 'connecting' | 'open' | 'closed'
}
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.
Close when the view unmounts
const sub = events.connect({ /* ... */ });
return () => sub.close(); // e.g. a React effect cleanup