Skip to content

Commit

Permalink
fix(Realtime): Remove all listeners after socket closed
Browse files Browse the repository at this point in the history
  • Loading branch information
kosssi committed May 7, 2019
1 parent 428fee1 commit 0563c81
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/cozy-realtime/src/Socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Socket {
constructor(url, token) {
this._url = url
this._token = token

this.removeAllListeners = this.removeAllListeners.bind(this)
this.on('close', this.removeAllListeners)
}

isOpen() {
Expand Down Expand Up @@ -136,6 +139,8 @@ class Socket {
close() {
if (this.isOpen()) {
this._socket.close()
} else {
this.removeAllListeners()
}
this._socket = null
}
Expand Down

0 comments on commit 0563c81

Please sign in to comment.