Skip to content

Commit 6d07e4d

Browse files
committed
lib: add success return bool in unsubscribe
1 parent 64fdae3 commit 6d07e4d

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/diagnostics_channel.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@ class ActiveChannel {
3232

3333
unsubscribe(subscription) {
3434
const index = ArrayPrototypeIndexOf(this._subscribers, subscription);
35-
if (index >= 0) {
36-
ArrayPrototypeSplice(this._subscribers, index, 1);
35+
if (index === -1) return false;
3736

38-
// When there are no more active subscribers, restore to fast prototype.
39-
if (!this._subscribers.length) {
40-
// eslint-disable-next-line no-use-before-define
41-
ObjectSetPrototypeOf(this, Channel.prototype);
42-
}
37+
ArrayPrototypeSplice(this._subscribers, index, 1);
38+
39+
// When there are no more active subscribers, restore to fast prototype.
40+
if (!this._subscribers.length) {
41+
// eslint-disable-next-line no-use-before-define
42+
ObjectSetPrototypeOf(this, Channel.prototype);
4343
}
44+
45+
return true;
4446
}
4547

4648
get hasSubscribers() {
@@ -79,7 +81,9 @@ class Channel {
7981
this.subscribe(subscription);
8082
}
8183

82-
unsubscribe() {}
84+
unsubscribe() {
85+
return false;
86+
}
8387

8488
get hasSubscribers() {
8589
return false;

0 commit comments

Comments
 (0)