0/24
22. Channels

Lesson 22: Channels

Streams have an init function that returns historical data. But sometimes you just want fire-and-forget events with no history.

live.channel() creates a lightweight pub/sub subscription:

export const alerts = live.channel('alerts');

No init function, no stored data. Subscribers only see events that happen after they connect. Perfect for notifications, typing indicators, or ephemeral signals.

Try it

  1. Create a notifications channel on the 'alerts' topic
  2. Create a notify(text) RPC that publishes a notification object to 'alerts' with event 'created'
  3. Each notification needs an id, text, and timestamp
WebSocket
0
No messages yet
User A
User B