- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
Custom event emitter #265
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
Custom event emitter #265
Conversation
| Codecov Report
 @@            Coverage Diff             @@
##              6.x     #265      +/-   ##
==========================================
+ Coverage   98.27%   98.36%   +0.09%     
==========================================
  Files          17       17              
  Lines        2140     2085      -55     
  Branches      623      606      -17     
==========================================
- Hits         2103     2051      -52     
+ Misses         37       34       -3
 Continue to review full report at Codecov. 
 | 
|  | ||
| prependListener(event, callback, once = false) { | ||
| this._addEventWrapper(event, callback, once); | ||
| return this.prependListener(event, callback, once); | 
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.
infinite loop ?
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.
I replaced super by this as a last-minute change, I don't even know why 😞
| * @param {string} [event] | ||
| */ | ||
| removeAllListeners(event) { | ||
| if (event !== undefined && this.eventsWrapper[event] !== undefined) { | 
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.
if event is defined but this.eventsWrapper[event] is not, we will execute the else code, and so remove all listeners of all events ??
| */ | ||
| once(roomId, callback) { | ||
| this.socket.once(roomId, callback); | ||
| addOnceListener(event, callback) { | 
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.
is it necessary to redefine these methods ?
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.
No, it is not. I removed it along with a few others (on, prependOnceListener, ...)
| @ballinette > good catches 👍 | 
Description
addOnceListenermethod, as it's more in line with other method names thanonce, which is now an alias (see below about aliases)Other related changes
windowmanipulation and the need to requireeventswhen on NodeJS sideKuzzleEventListenerobject is now an ES6 class (added to babel configuration for conversion to ES5)oncelisteners are handledKuzzleEventEmitterclass and socketio's dedicated event emitteroff+removeListener=>removeListeneremitEvent+emit=>emitonandonceare now aliases specific to our Javascript SDK implementation, as those two are very commonplace when it comes to event emitters in JS. This is (and should be) the only case where an alias existsOther changes