Skip to content

Miscellaneous

subscribeToChannel()

subscribeToChannel() — returns void

Available in: controller

Subscribe to a channel and stream events to the client via SSE. Opens a long-lived SSE connection that delivers matching events until the client disconnects or the timeout is reached. For the “memory” adapter, subscribes to the in-memory Channel engine and buffers events for delivery. For the “database” adapter, polls the wheels_events table at regular intervals.

NameTypeRequiredDefaultDescription
channelstringyesThe channel name to subscribe to (e.g. “user.42”).
eventsstringnoComma-delimited list of event types to filter. Empty = all events.
lastEventIdstringnoResume from this event ID. Auto-detected from Last-Event-ID header if empty.
adapterstringno“memory” (default) or “database”.
pollIntervalnumericno2Seconds between polls for database adapter (default 2).
timeoutnumericno300Maximum connection duration in seconds (default 300 = 5 minutes).
heartbeatIntervalnumericno15Seconds between keep-alive pings (default 15).