Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document events + one alteration for consistency #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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