mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-01 13:32:14 +00:00
docs: update pubsub example
This commit is contained in:
parent
4e01c094bc
commit
99873e877b
@ -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)
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user