File tree 1 file changed +20
-3
lines changed
1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -39,18 +39,35 @@ class Dispatcher extends EventEmitter {
39
39
}
40
40
}
41
41
42
+ const kOnDrain = Symbol ( 'onDrain' )
43
+ const kOnConnect = Symbol ( 'onConnect' )
44
+ const kOnDisconnect = Symbol ( 'onDisconnect' )
45
+ const kOnConnectionError = Symbol ( 'onConnectionError' )
46
+
42
47
class ComposedDispatcher extends Dispatcher {
43
- #dispatcher = null
44
- #dispatch = null
48
+ #dispatcher
49
+ #dispatch
45
50
46
51
constructor ( dispatcher , dispatch ) {
47
52
super ( )
53
+
48
54
this . #dispatcher = dispatcher
49
55
this . #dispatch = dispatch
56
+
57
+ this [ kOnDrain ] = ( ...args ) => this . emit ( 'drain' , ...args )
58
+ this [ kOnConnect ] = ( ...args ) => this . emit ( 'connect' , ...args )
59
+ this [ kOnDisconnect ] = ( ...args ) => this . emit ( 'disconnect' , ...args )
60
+ this [ kOnConnectionError ] = ( ...args ) => this . emit ( 'connectionError' , ...args )
61
+
62
+ this . #dispatcher
63
+ . on ( 'drain' , this [ kOnDrain ] )
64
+ . on ( 'connect' , this [ kOnConnect ] )
65
+ . on ( 'disconnect' , this [ kOnDisconnect ] )
66
+ . on ( 'connectionError' , this [ kOnConnectionError ] )
50
67
}
51
68
52
69
dispatch ( ...args ) {
53
- this . #dispatch( ...args )
70
+ return this . #dispatch( ...args )
54
71
}
55
72
56
73
close ( ...args ) {
You can’t perform that action at this time.
0 commit comments