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,22 @@ 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
+ /** It enables automatic capturing of promise rejection.
28
+ * Default: false.
29
+ *
30
+ * Experimental !
31
+ */
32
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
33
+ var captureRejections : Boolean
34
+ }
19
35
20
36
/**
21
37
* EventEmitter Interface
@@ -148,8 +164,29 @@ object EventEmitter extends js.Object {
148
164
*/
149
165
var defaultMaxListeners : Int = js.native
150
166
167
+ /** Change the default captureRejections option on all new EventEmitter objects.
168
+ *
169
+ * experimental!
170
+ */
171
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
172
+ var captureRejections : Boolean = js.native
173
+
174
+ /** experimental! */
175
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
176
+ var captureRejectionSymbol : js.Symbol = js.native
177
+
151
178
@ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
152
179
def once (emitter : IEventEmitter , eventName : String ): js.Promise [js.Array [js.Any ]] = js.native
180
+ // TODO: Return AsyncIterator
181
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
182
+ def on (emitter : IEventEmitter , eventName : String ): js.Any = js.native
183
+
184
+ // TODO: Return AsyncIterator
185
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
186
+ def on (emitter : IEventEmitter , eventName : js.Symbol ): js.Any = js.native
187
+
188
+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
189
+ var errorMonitor : js.Symbol = js.native
153
190
}
154
191
155
192
@ js.native
0 commit comments