Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node emits "online" event once online #93

Closed
wants to merge 10 commits into from
Closed

Conversation

pgte
Copy link
Contributor

@pgte pgte commented Jun 30, 2017

To support ipfs/js-ipfs#891

src/index.js Outdated
@@ -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.

👍🏽

@pgte
Copy link
Contributor Author

pgte commented Jul 6, 2017

As discussed, switched to "start" and "stop" events. Also, replaced .isOn() with .isStarted().

@pgte
Copy link
Contributor Author

pgte commented Jul 6, 2017

Rebased PR after opening, now GH is all confused about the diff. Closing this one to create a new PR..

@pgte pgte closed this Jul 6, 2017
@RichardLitt RichardLitt removed the status/in-progress In progress label Jul 6, 2017
@daviddias daviddias deleted the feat/emit-online branch July 7, 2017 12:54
achingbrain pushed a commit that referenced this pull request Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants