Skip to content

Commit

Permalink
fix: forward dispatch return value
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Jun 25, 2024
1 parent dd98299 commit 1512421
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/dispatcher/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ class Dispatcher extends EventEmitter {
}
}

const kOnDrain = Symbol('onDrain')
const kOnConnect = Symbol('onConnect')
const kOnDisconnect = Symbol('onDisconnect')
const kOnConnectionError = Symbol('onConnectionError')

class ComposedDispatcher extends Dispatcher {
#dispatcher = null
#dispatch = null
Expand All @@ -47,10 +52,21 @@ class ComposedDispatcher extends Dispatcher {
super()
this.#dispatcher = dispatcher
this.#dispatch = dispatch

this[kOnDrain] = () => this.emit('drain')
this[kOnConnect] = () => this.emit('connect')
this[kOnDisconnect] = () => this.emit('disconnect')
this[kOnConnectionError] = () => this.emit('connectionError')

this.#dispatcher
.on('drain', this[kOnDrain])
.on('connect', this[kOnConnect])
.on('disconnect', this[kOnDisconnect])
.on('connectionError', this[kOnConnectionError])
}

dispatch (...args) {
this.#dispatch(...args)
return this.#dispatch(...args)
}

close (...args) {
Expand Down

0 comments on commit 1512421

Please sign in to comment.