Skip to content

Commit 5e009d1

Browse files
committed
Simplify the code
1 parent cfca37f commit 5e009d1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/client/doc.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ Doc.prototype.destroy = function(callback) {
106106
doc.whenNothingPending(function() {
107107
if (doc.wantSubscribe) {
108108
doc.unsubscribe(function(err) {
109-
if (!err) doc.connection._destroyDoc(doc);
110-
if (callback) return callback(err);
111-
if (err) this.emit('error', err);
109+
if (err) {
110+
if (callback) callback(err);
111+
else this.emit('error', err);
112+
return;
113+
}
114+
doc.connection._destroyDoc(doc);
115+
if (callback) callback();
112116
});
113117
} else {
114118
doc.connection._destroyDoc(doc);

0 commit comments

Comments
 (0)