Skip to content

Commit

Permalink
Resolved #334 Socket.on... returns disposer function
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen committed Feb 15, 2024
1 parent 44e1bc1 commit 2fc28d6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* [#55](https://github.com/rikulo/socket.io-client-dart/issues/55) how to custom parser
* [#322](https://github.com/rikulo/socket.io-client-dart/pull/322) added emitWithAckAsync
* [#334](https://github.com/rikulo/socket.io-client-dart/pull/334) Socket.on... returns disposer function

## 2.0.3+1

Expand Down
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,6 @@ Contribution of all kinds is welcome. Please read [Contributing.md](https://gith

## Contributors

- Thanks [@felangel](https://github.com/felangel) for https://github.com/rikulo/socket.io-client-dart/issues/7
- Thanks [@Oskang09](https://github.com/Oskang09) for https://github.com/rikulo/socket.io-client-dart/issues/21
- Thanks [@bruce3x](https://github.com/bruce3x) for https://github.com/rikulo/socket.io-client-dart/issues/25
- Thanks [@Kavantix](https://github.com/Kavantix) for https://github.com/rikulo/socket.io-client-dart/issues/26
- Thanks [@luandnguyen](https://github.com/luandnguyen) for https://github.com/rikulo/socket.io-client-dart/issues/59
- Thanks [@jorgefspereira](https://github.com/jorgefspereira) for https://github.com/rikulo/socket.io-client-dart/pull/177
- Thanks [@fzyzcjy](https://github.com/fzyzcjy) for https://github.com/rikulo/socket.io-client-dart/pull/188
- Thanks [@darwin-morocho](https://github.com/darwin-morocho) for https://github.com/rikulo/socket.io-client-dart/pull/189
- Thanks [@chatziko](https://github.com/chatziko) for https://github.com/rikulo/socket.io-client-dart/pull/237
- Thanks [@Astray-git](https://github.com/Astray-git) for https://github.com/rikulo/socket.io-client-dart/pull/313
- Thanks [@Astray-git](https://github.com/Astray-git) for https://github.com/rikulo/socket.io-client-dart/pull/310
- Thanks [@Frank3K](https://github.com/Frank3K) for https://github.com/rikulo/socket.io-client-dart/pull/338
<a href="https://github.com/rikulo/socket.io-client-dart/graphs/contributors">
<img src="https://contrib.rocks/image?repo=rikulo/socket.io-client-dart" />
</a>
52 changes: 26 additions & 26 deletions lib/src/darty.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,56 @@ import 'package:socket_io_common/src/util/event_emitter.dart';

/// Default event listeners for dart way API.
extension DartySocket on Socket {
void onConnect(EventHandler handler) {
on('connect', handler);
Function() onConnect(EventHandler handler) {
return on('connect', handler);
}

void onConnectError(EventHandler handler) {
on('connect_error', handler);
Function() onConnectError(EventHandler handler) {
return on('connect_error', handler);
}

void onConnectTimeout(EventHandler handler) {
on('connect_timeout', handler);
Function() onConnectTimeout(EventHandler handler) {
return on('connect_timeout', handler);
}

void onConnecting(EventHandler handler) {
on('connecting', handler);
Function() onConnecting(EventHandler handler) {
return on('connecting', handler);
}

void onDisconnect(EventHandler handler) {
on('disconnect', handler);
Function() onDisconnect(EventHandler handler) {
return on('disconnect', handler);
}

void onError(EventHandler handler) {
this.io.on('error', handler);
Function() onError(EventHandler handler) {
return this.io.on('error', handler);
}

void onReconnect(EventHandler handler) {
this.io.on('reconnect', handler);
Function() onReconnect(EventHandler handler) {
return this.io.on('reconnect', handler);
}

void onReconnectAttempt(EventHandler handler) {
this.io.on('reconnect_attempt', handler);
Function() onReconnectAttempt(EventHandler handler) {
return this.io.on('reconnect_attempt', handler);
}

void onReconnectFailed(EventHandler handler) {
this.io.on('reconnect_failed', handler);
Function() onReconnectFailed(EventHandler handler) {
return this.io.on('reconnect_failed', handler);
}

void onReconnectError(EventHandler handler) {
this.io.on('reconnect_error', handler);
Function() onReconnectError(EventHandler handler) {
return this.io.on('reconnect_error', handler);
}

void onReconnecting(EventHandler handler) {
on('reconnecting', handler);
Function() onReconnecting(EventHandler handler) {
return on('reconnecting', handler);
}

void onPing(EventHandler handler) {
this.io.on('ping', handler);
Function() onPing(EventHandler handler) {
return this.io.on('ping', handler);
}

void onPong(EventHandler handler) {
on('pong', handler);
Function() onPong(EventHandler handler) {
return on('pong', handler);
}
}

Expand Down

0 comments on commit 2fc28d6

Please sign in to comment.