Skip to content
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class Node extends EventEmitter {
return each(this.modules.discovery, (d, cb) => d.start(cb), cb)
}
cb()

this.emit('online')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced that online/offline is the right wording here. In js-ipfs we have:

image

start/stop sounds better because online has a lot of assumptions today. To me, start/stop say "hey, the thing you set up, is running".

Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, "online" is somewhat ambiguous, and not the goal. I'd say started and stopped are what are the really important events for the user (at the libp2p and ifs levels).

Following that trail, I think this leads to replacing .isOnline() with .isStarted(), no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pgte I like that :) (maybe isRunning?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should use the same verbs, otherwise it may get confusing to users, no?
The other alternative is to be explicit (in the docs) about the state machine (states) and the transitions (events). Example:

starting event -> starting state -> started event -> running state -> stopping event -> stopped state

Makes sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

},
(cb) => {
if (this._dht) {
Expand Down