Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
docs: improve start example (#1501)
Browse files Browse the repository at this point in the history
The `start` example was missing the `ready` event. The example
is now more similar to the `stop` example.
  • Loading branch information
vmx authored and alanshaw committed Aug 13, 2018
1 parent 661c0bc commit 59bc6d5
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,24 +361,28 @@ This method is asynchronous. There are several ways to be notified when the node
```js
const node = new IPFS({ start: false })

// Use a promise:
node.start()
.then(() => console.log('Node started!'))
.catch(error => console.error('Node failed to start!', error))

// OR use a callback:
node.start(error => {
if (error) {
console.error('Node failed to start!', error)
return
}
console.log('Node started!')
})
node.on('ready', () => {
console.log('Node is ready to use!')

// Use a promise:
node.start()
.then(() => console.log('Node started!'))
.catch(error => console.error('Node failed to start!', error))

// OR use a callback:
node.start(error => {
if (error) {
console.error('Node failed to start!', error)
return
}
console.log('Node started!')
})

// OR use events:
node.on('error', error => console.error('Something went terribly wrong!', error))
node.on('start', () => console.log('Node started!'))
node.start()
// OR use events:
node.on('error', error => console.error('Something went terribly wrong!', error))
node.on('start', () => console.log('Node started!'))
node.start()
})
```

#### `node.stop([callback])`
Expand Down

0 comments on commit 59bc6d5

Please sign in to comment.