0/24
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

  1. Rename the 'counter' topic to 'score' everywhere - in the stream, in ctx.publish(), and rename the stream export to score
  2. Add a statusText variable (initialized to 'Waiting...')
  3. Add a setStatus RPC that updates it and publishes to 'status'
  4. Add a status stream on the 'status' topic

Two streams, two topics, one file - each completely independent.

WebSocket
0
No messages yet
/