diff --git a/examples/pubsub/1.js b/examples/pubsub/1.js index e522088d..48797a7c 100644 --- a/examples/pubsub/1.js +++ b/examples/pubsub/1.js @@ -54,11 +54,13 @@ parallel([ ], (err) => { if (err) { throw err } - node1.pubsub.on('news', (msg) => console.log(msg.from, msg.data.toString())) - node1.pubsub.subscribe('news') - - setInterval(() => { - node2.pubsub.publish('news', Buffer.from('Bird bird bird, bird is the word!')) - }, 1000) + node1.pubsub.subscribe('news', + (msg) => console.log(msg.from, msg.data.toString(), + () => { + setInterval(() => { + node2.pubsub.publish('news', Buffer.from('Bird bird bird, bird is the word!')) + }, 1000) + }) + ) }) })