docs: update pubsub example

This commit is contained in:
David Dias 2018-02-15 20:15:18 +01:00
parent 4e01c094bc
commit 99873e877b

View File

@ -54,11 +54,13 @@ parallel([
], (err) => { ], (err) => {
if (err) { throw err } if (err) { throw err }
node1.pubsub.on('news', (msg) => console.log(msg.from, msg.data.toString())) node1.pubsub.subscribe('news',
node1.pubsub.subscribe('news') (msg) => console.log(msg.from, msg.data.toString(),
() => {
setInterval(() => { setInterval(() => {
node2.pubsub.publish('news', Buffer.from('Bird bird bird, bird is the word!')) node2.pubsub.publish('news', Buffer.from('Bird bird bird, bird is the word!'))
}, 1000) }, 1000)
})
)
}) })
}) })