Skip to content

Commit

Permalink
fine tune and add the contributor @ThinkDigitalSoftware for #15
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen committed Dec 27, 2019
1 parent 28852be commit 5fada1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ If you are new to Git or GitHub, please read [this guide](https://help.github.co

## Contributors
* Thanks [@felangel](https://github.com/felangel) for https://github.com/rikulo/socket.io-dart/issues/7
* Thanks [@ThinkDigitalSoftware](https://github.com/ThinkDigitalSoftware) for https://github.com/rikulo/socket.io-dart/pull/15
13 changes: 8 additions & 5 deletions lib/src/namespace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Namespace extends EventEmitter {
if (err) return fn(err);

// if no middleware left, summon callback
if (fns.length < index + 1) return fn(null);
if (fns.length <= index + 1) return fn(null);

// go on to next
run0(index + 1, fns, socket, fn);
Expand Down Expand Up @@ -189,12 +189,13 @@ class Namespace extends EventEmitter {
///
/// @return {Namespace} self
/// @api public
void send([args]) {
write(args);
Namespace send([args]) {
return write(args);
}

void write([args]) {
Namespace write([args]) {
emit('message', args);
return this;
}

/// Gets a list of clients.
Expand All @@ -213,10 +214,12 @@ class Namespace extends EventEmitter {
/// Sets the compress flag.
///
/// @param {Boolean} if `true`, compresses the sending data
/// @return {Namespace} self
/// @api public
void compress(compress) {
Namespace compress(compress) {
flags = flags.isEmpty ? flags : {};
flags['compress'] = compress;
return this;
}
}

Expand Down

2 comments on commit 5fada1f

@ThinkDigitalSoftware
Copy link
Contributor

@ThinkDigitalSoftware ThinkDigitalSoftware commented on 5fada1f Dec 27, 2019

Choose a reason for hiding this comment

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

Why do you return this on these?
There's a lint rule that says we shouldn't.
https://dart-lang.github.io/linter/lints/avoid_returning_this.html

@jumperchen
Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, in Dart code, but we don't want to break the API like the original JS implementation - https://github.com/socketio/socket.io/blob/master/lib/namespace.js
Maybe the JS style is not useful in Dart but it's not a question of this merged.

Please sign in to comment.