Skip to content

Commit

Permalink
document events, one alteration for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
David Mark Clements committed Jul 8, 2019
1 parent 613f763 commit fa5ce6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ A new peer has been discovered on the network and has been queued for connection
- `id`. Buffer.
- `topic`. Buffer. The identifier which this peer was discovered under.

#### `swarm.on('updated', ({ key }) => {})`
#### `swarm.on('updated', (key) => {})`

Emitted once a discovery cycle for a particular topic has completed. The topic can be identified by the `key` property of the emitted object. After this event the peer will wait for period of between 5 and 10 minutes before looking for new peers on that topic again.
Emitted once a discovery cycle for a particular topic has completed. The topic can be identified by the `key` property of the emitted object. After this event the peer will wait for period of between 5 and 10 minutes before looking for new peers on that topic again.

#### `swarm.on('join', (key, opts) => {})`

Once a topic has been sucessfully joined this event is emitted with the key for the joined topic and the options object that was passed to join for this particular key.

#### `swarm.on('leave', (key) => {})`

Emitted with the relevant topics key, when a topic has been succesfully left.
2 changes: 1 addition & 1 deletion swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Swarm extends EventEmitter {
? network.announce(key, { lookup })
: network.lookup(key)

topic.on('update', () => this.emit('updated', { key }))
topic.on('update', () => this.emit('updated', key))
if (lookup) {
topic.on('peer', (peer) => {
this.emit('peer', peer)
Expand Down

0 comments on commit fa5ce6c

Please sign in to comment.