From 99873e877b8ab046fcce67fa8092bb995149da2c Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 15 Feb 2018 20:15:18 +0100 Subject: [PATCH] docs: update pubsub example --- examples/pubsub/1.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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) + }) + ) }) })