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

Commit e2c2ba3

Browse files
author
Alan Shaw
committed
fix: remove events and callbacks info from the README (#2776)
1 parent cf8aa12 commit e2c2ba3

File tree

1 file changed

+2
-139
lines changed

1 file changed

+2
-139
lines changed

README.md

Lines changed: 2 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ We've come a long way, but this project is still in Alpha, lots of development i
7777
- [`options.ipld`](#optionsipld)
7878
- [`options.libp2p`](#optionslibp2p)
7979
- [`options.connectionManager`](#optionsconnectionmanager)
80-
- [Events](#events)
81-
- [`node.ready`](#nodeready)
82-
- [`node.start()`](#nodestart)
83-
- [`node.stop()`](#nodestop)
8480
- [Core API](#core-api)
8581
- [Files](#files)
8682
- [Graph](#graph)
@@ -155,6 +151,8 @@ npm install ipfs --global
155151

156152
The CLI is available by using the command `jsipfs` in your terminal. This is aliased, instead of using `ipfs`, to make sure it does not conflict with the [Go implementation](https://github.com/ipfs/go-ipfs).
157153

154+
Once installed, please follow the [Getting Started Guide](https://docs.ipfs.io/introduction/usage/) to learn how to initialize your node and run the daemon.
155+
158156
### Use in the browser
159157

160158
Learn how to bundle with browserify and webpack in the [`examples`](https://github.com/ipfs/js-ipfs/tree/master/examples) folder.
@@ -249,23 +247,6 @@ const node = await IPFS.create([options])
249247

250248
Creates and returns a ready to use instance of an IPFS node.
251249

252-
<details><summary>Alternative method to construct an IPFS node</summary>
253-
254-
The recommended method of creating a new IPFS node is to use the `IPFS.create` method. However, IPFS is a `class`, and can also be constructed using the `new` keyword:
255-
256-
```js
257-
const node = new IPFS([options])
258-
```
259-
260-
At this point, your node has been created but is **not** ready to use. You must either attach a listener for the "ready" event _or_ wait for the `node.ready` promise to resolve:
261-
262-
```js
263-
node.on('ready', () => { /* Node is now ready to use */ })
264-
// OR
265-
await node.ready
266-
```
267-
</details>
268-
269250
Use the `options` argument to specify advanced configuration. It is an object with any of these properties:
270251

271252
##### `options.repo`
@@ -585,43 +566,6 @@ You can see the bundle in action in the [custom libp2p example](examples/custom-
585566

586567
Configure the libp2p connection manager.
587568

588-
#### Events
589-
590-
IPFS instances are Node.js [EventEmitters](https://nodejs.org/dist/latest-v8.x/docs/api/events.html#events_class_eventemitter). You can listen for events by calling `node.on('event', handler)`:
591-
592-
```js
593-
const node = await IPFS.create({ repo: '/var/ipfs/data' })
594-
node.on('error', errorObject => console.error(errorObject))
595-
```
596-
597-
- `error` is always accompanied by an `Error` object with information about the error that occurred.
598-
599-
```js
600-
node.on('error', error => {
601-
console.error(error.message)
602-
})
603-
```
604-
605-
- `init` is emitted after a new repo has been initialized. It will not be emitted if you set the `init: false` option on the constructor.
606-
607-
- `ready` is emitted when a node is ready to use. This is the final event you will receive when creating a node (after `init` and `start`).
608-
609-
When creating a new IPFS node, you should almost always wait for the `ready` event before calling methods or interacting with the node.
610-
611-
- `start` is emitted when a node has started listening for connections. It will not be emitted if you set the `start: false` option on the constructor.
612-
613-
- `stop` is emitted when a node has closed all connections and released access to its repo. This is usually the result of calling [`node.stop()`](#nodestop).
614-
615-
#### `node.ready`
616-
617-
A promise that resolves when the node is ready to use. Should be used when constructing an IPFS node using `new`. You don't need to use this if you're using [`await IPFS.create`](#ipfs-constructor). e.g.
618-
619-
```js
620-
const node = new IPFS()
621-
await node.ready
622-
// Ready to use!
623-
```
624-
625569
#### `node.start()`
626570

627571
Start listening for connections with other IPFS nodes on the network. In most cases, you do not need to call this method — `IPFS.create()` will automatically do it for you.
@@ -640,48 +584,6 @@ try {
640584
}
641585
```
642586
643-
<details><summary>Starting using callbacks and events</summary>
644-
645-
If you pass a function to this method, it will be called when the node is started (Note: this method will **not** return a promise if you use a callback function).
646-
647-
```js
648-
// Note: you can use the class constructor style for more
649-
// idiomatic callback/events style code
650-
const node = new IPFS({ start: false })
651-
652-
node.on('ready', () => {
653-
console.log('Node is ready to use but not started!')
654-
655-
node.start(error => {
656-
if (error) {
657-
return console.error('Node failed to start!', error)
658-
}
659-
console.log('Node started!')
660-
})
661-
})
662-
```
663-
664-
Alternatively you can listen for the [`start` event](#events):
665-
666-
```js
667-
// Note: you can use the class constructor style for more
668-
// idiomatic callback/events style code
669-
const node = new IPFS({ start: false })
670-
671-
node.on('ready', () => {
672-
console.log('Node is ready to use but not started!')
673-
node.start()
674-
})
675-
676-
node.on('error', error => {
677-
console.error('Something went terribly wrong!', error)
678-
})
679-
680-
node.on('start', () => console.log('Node started!'))
681-
```
682-
683-
</details>
684-
685587
#### `node.stop()`
686588
687589
Close and stop listening for connections with other IPFS nodes, then release access to the node’s repo.
@@ -700,45 +602,6 @@ try {
700602
}
701603
```
702604
703-
<details><summary>Stopping using callbacks and events</summary>
704-
705-
If you pass a function to this method, it will be called when the node is stopped (Note: this method will **not** return a promise if you use a callback function).
706-
707-
```js
708-
// Note: you can use the class constructor style for more
709-
// idiomatic callback/events style code
710-
const node = new IPFS()
711-
712-
node.on('ready', () => {
713-
console.log('Node is ready to use!')
714-
715-
node.stop(error => {
716-
if (error) {
717-
return console.error('Node failed to stop cleanly!', error)
718-
}
719-
console.log('Node stopped!')
720-
})
721-
})
722-
```
723-
724-
Alternatively you can listen for the [`stop` event](#events).
725-
726-
```js
727-
const node = new IPFS()
728-
729-
node.on('ready', () => {
730-
console.log('Node is ready to use!')
731-
node.stop()
732-
})
733-
734-
node.on('error', error => {
735-
console.error('Something went terribly wrong!', error)
736-
})
737-
738-
node.on('stop', () => console.log('Node stopped!'))
739-
```
740-
</details>
741-
742605
#### Core API
743606
744607
[![](https://github.com/ipfs/interface-ipfs-core/raw/master/img/badge.png)](https://github.com/ipfs/interface-ipfs-core)

0 commit comments

Comments
 (0)