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

Commit 59bc6d5

Browse files
vmxalanshaw
authored andcommitted
docs: improve start example (#1501)
The `start` example was missing the `ready` event. The example is now more similar to the `stop` example.
1 parent 661c0bc commit 59bc6d5

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -361,24 +361,28 @@ This method is asynchronous. There are several ways to be notified when the node
361361
```js
362362
const node = new IPFS({ start: false })
363363

364-
// Use a promise:
365-
node.start()
366-
.then(() => console.log('Node started!'))
367-
.catch(error => console.error('Node failed to start!', error))
368-
369-
// OR use a callback:
370-
node.start(error => {
371-
if (error) {
372-
console.error('Node failed to start!', error)
373-
return
374-
}
375-
console.log('Node started!')
376-
})
364+
node.on('ready', () => {
365+
console.log('Node is ready to use!')
366+
367+
// Use a promise:
368+
node.start()
369+
.then(() => console.log('Node started!'))
370+
.catch(error => console.error('Node failed to start!', error))
371+
372+
// OR use a callback:
373+
node.start(error => {
374+
if (error) {
375+
console.error('Node failed to start!', error)
376+
return
377+
}
378+
console.log('Node started!')
379+
})
377380

378-
// OR use events:
379-
node.on('error', error => console.error('Something went terribly wrong!', error))
380-
node.on('start', () => console.log('Node started!'))
381-
node.start()
381+
// OR use events:
382+
node.on('error', error => console.error('Something went terribly wrong!', error))
383+
node.on('start', () => console.log('Node started!'))
384+
node.start()
385+
})
382386
```
383387

384388
#### `node.stop([callback])`

0 commit comments

Comments
 (0)