7. Topics
Lesson 7: Topics
The topic string is what connects publishers and subscribers. When an RPC calls ctx.publish('score', ...), only streams subscribed to 'score' receive the update.
Think of topics as addresses - publishers send to an address, and subscribers listen on that same address.
A module can have multiple streams on different topics, each tracking different data.
Try it
- Rename the
'counter'topic to'score'everywhere - in the stream, inctx.publish(), and rename the stream export toscore - Add a
statusTextvariable (initialized to'Waiting...') - Add a
setStatusRPC that updates it and publishes to'status' - Add a
statusstream on the'status'topic
Two streams, two topics, one file - each completely independent.
WebSocket
0
No messages yet