-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Conversation
The init event was only being emitted during initialization of a new repo. If one already existed that event was not firing. This syncs up the behavior between these two situations so that they log, set self.state, and emit identically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @wraithgar. Mind adding a test to make sure we don't break this in the future?
src/core/boot.js
Outdated
@@ -32,6 +32,7 @@ module.exports = (self) => { | |||
(cb) => { | |||
self.log('initialized') | |||
self.state.initialized() | |||
self.emit('init'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will failing linting (semicolons)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that. Linting already reports 87 problems for me in master so that one got lost in the noise. Pushed a fix.
@diasdavid I'd be glad to add tests but would need a little help to be pointed in the right direction. As far as I can see in this repo there isn't anything testing the events firing. Am I just not looking in the right direction or would these be wholly new? |
Isn’t the point of the I feel like this event should be named something different that indicates what it is actually about. Maybe |
It won't fire twice here. In boot.js, self.init is only called if maybeOpenRepo returns false, and the callback after the emitted init event returns true to the callback. As far as the semantics of the init event, this is what I thought being discussed in #1058. I may have misunderstood. It would be possible to just emit a |
Ah, you’re right; I misread.
I don’t think the semantics of the event really got any discussion there, though. Nobody actually said what the event was doing was wrong or unexpected — only that it didn’t fit @pgte’s use case. I think there are two different things in that issue that make more sense to address:
|
If it's a new event it makes sense to do it right in pre-start after self._peerInfo is defined (because from that moment on calls to self.id() will return something). |
The matter of |
Fair enough! But maybe useful to wait for feedback from @pgte and some discussion on the original issue to zero in on the right change before continuing with the implementation here? |
@wraithgar can this be closed? Reading the comments above it sounds as though the |
For #1058
The init event was only being emitted during initialization of
a new repo. If one already existed that event was not firing.
This syncs up the behavior between these two situations so that they
log, set state, and emit identically.