Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 98fa4e0

Browse files
committed
Update events for Node.js v14
1 parent 2fa701c commit 98fa4e0

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

app/current/src/main/scala/io/scalajs/nodejs/events/EventEmitter.scala

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.scalajs.nodejs.events
22

33
import com.thoughtworks.enableIf
4+
import net.exoego.scalajs.types.util.Factory
45

56
import scala.scalajs.js
67
import scala.scalajs.js.annotation.JSImport
@@ -15,7 +16,20 @@ import scala.scalajs.js.annotation.JSImport
1516
*/
1617
@js.native
1718
@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+
}
1933

2034
/**
2135
* EventEmitter Interface
@@ -148,8 +162,29 @@ object EventEmitter extends js.Object {
148162
*/
149163
var defaultMaxListeners: Int = js.native
150164

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+
151176
@enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12)
152177
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
153188
}
154189

155190
@js.native

0 commit comments

Comments
 (0)