From 59bc6d5c9a217a2b2c535cce6d0aac2f0b40ea79 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Mon, 13 Aug 2018 14:16:51 +0200 Subject: [PATCH] docs: improve start example (#1501) The `start` example was missing the `ready` event. The example is now more similar to the `stop` example. --- README.md | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 93b553bc0c..2a363398cb 100644 --- a/README.md +++ b/README.md @@ -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])`