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
- Create a
notificationschannel on the'alerts'topic - Create a
notify(text)RPC that publishes a notification object to'alerts'with event'created' - Each notification needs an
id,text, andtimestamp
WebSocket
0
No messages yet