Skip to content

Commit b4abd20

Browse files
committed
fix(remove): don't throw error if listener does not exist
1 parent 4f763c6 commit b4abd20

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,10 @@ class Signal {
106106

107107
const listenerId = this._getListernerIndex(cb, context)
108108

109-
if (listenerId === -1) {
110-
throw new Error('Signal.remove() : Listener does not exist')
109+
if (listenerId !== -1) {
110+
this._listeners.splice(listenerId, 1)
111111
}
112112

113-
this._listeners.splice(listenerId, 1)
114-
115113
return this
116114
}
117115

0 commit comments

Comments
 (0)