Skip to content

Commit 61ceb8c

Browse files
committed
docs: update example on the readme
1 parent 7fa767c commit 61ceb8c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

README.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ const FloodSub = require('libp2p-floodsub')
3535

3636
const fsub = new FloodSub(libp2pNodeInstance)
3737

38-
fsub.on('fruit', (data) => {
39-
console.log(data)
38+
fsub.start((err) => {
39+
if (err) {
40+
console.log('Upsy', err)
41+
}
42+
fsub.on('fruit', (data) => {
43+
console.log(data)
44+
})
45+
fsub.subscribe('fruit')
46+
47+
fsub.publish('fruit', new Buffer('banana'))
4048
})
41-
fsub.subscribe('fruit')
42-
43-
fsub.publish('fruit', new Buffer('banana'))
4449
```
4550

4651
## API

0 commit comments

Comments
 (0)