1
1
package io .scalajs .nodejs .events
2
2
3
3
import com .thoughtworks .enableIf
4
+ import net .exoego .scalajs .types .util .Factory
4
5
5
6
import scala .scalajs .js
6
7
import scala .scalajs .js .annotation .JSImport
@@ -15,7 +16,20 @@ import scala.scalajs.js.annotation.JSImport
15
16
*/
16
17
@ js.native
17
18
@ JSImport (" events" , " EventEmitter" )
18
- class EventEmitter extends IEventEmitter
19
+ class EventEmitter () extends IEventEmitter {
20
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
21
+ def this (options : EventEmitterOptions ) = this ()
22
+ }
23
+
24
+ @ Factory
25
+ trait EventEmitterOptions extends js.Object {
26
+
27
+ /**
28
+ *
29
+ */
30
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
31
+ var captureRejections : Boolean = js.native
32
+ }
19
33
20
34
/**
21
35
* EventEmitter Interface
@@ -148,8 +162,29 @@ object EventEmitter extends js.Object {
148
162
*/
149
163
var defaultMaxListeners : Int = js.native
150
164
165
+ /** Change the default captureRejections option on all new EventEmitter objects.
166
+ *
167
+ * experimental!
168
+ */
169
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
170
+ var captureRejections : Boolean = js.native
171
+
172
+ /** experimental! */
173
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
174
+ var captureRejectionSymbol : js.Symbol = js.native
175
+
151
176
@ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
152
177
def once (emitter : IEventEmitter , eventName : String ): js.Promise [js.Array [js.Any ]] = js.native
178
+ // TODO: Return AsyncIterator
179
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
180
+ def on (emitter : IEventEmitter , eventName : String ): js.Any = js.native
181
+
182
+ // TODO: Return AsyncIterator
183
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
184
+ def on (emitter : IEventEmitter , eventName : js.Symbol ): js.Any = js.native
185
+
186
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
187
+ var errorMonitor : js.Symbol = js.native
153
188
}
154
189
155
190
@ js.native
0 commit comments