Skip to content

Commit

Permalink
fix #167
Browse files Browse the repository at this point in the history
  • Loading branch information
timaschew committed Jul 26, 2016
1 parent 1274390 commit 4546ada
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/record/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,14 @@ Record.prototype.unsubscribe = function( pathOrCallback, callback ) {
* @returns {void}
*/
Record.prototype.discard = function() {
this.usages--;

if( this.usages <= 0 ) {
this.whenReady( function() {
this.emit( 'destroyPending' );
this._discardTimeout = setTimeout( this._onTimeout.bind( this, C.EVENT.ACK_TIMEOUT ), this._options.subscriptionTimeout );
this._connection.sendMsg( C.TOPIC.RECORD, C.ACTIONS.UNSUBSCRIBE, [ this.name ] );
}.bind( this ) );
}
this.whenReady( function() {
this.usages--;
if( this.usages <= 0 ) {
this.emit( 'destroyPending' );
this._discardTimeout = setTimeout( this._onTimeout.bind( this, C.EVENT.ACK_TIMEOUT ), this._options.subscriptionTimeout );
this._connection.sendMsg( C.TOPIC.RECORD, C.ACTIONS.UNSUBSCRIBE, [ this.name ] );
}
}.bind( this ) );
};

/**
Expand Down

0 comments on commit 4546ada

Please sign in to comment.