josephg / josephg/ShareJS

"unsubscribed" event is never triggered (with fix)

Open
#351 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5k
Forks
454
PR merge metrics
No merged PRs in 30d

Description

I'm using WebSocket as the socket mechanism and when the server unexpectedly drops the connection, the "unsubscribed" event is never emitted due to the bug in the following 2 lines:

``` js
this.subscribed = false;
if (this.subscribed) this.emit('unsubscribed'); // never triggered!!
```

located in lib/client/doc.js:407

Here is my fix:

``` js
var wasSubscribed = this.subscribed;
this.subscribed = false;
if (wasSubscribed) this.emit('unsubscribed');
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.