Event for listeners to subscribe to. Subscribes a function to run when this event is emitted.
Use like const unsubscriber = event(callback)
Unsubscriber function to run to stop calling the passed-in function when the event is emitted
ProtectedassertCheck to make sure this emitter is not disposed. Throw if it is
Disposes of this event, preparing it to release from memory
ProtecteddisposeDisposes of this event, preparing it to release from memory. Added here so children can override emit and still call the base functionality.
Runs the subscriptions for the event
Event data to provide to subscribed callbacks
ProtectedemitFunction that runs the subscriptions for the event. Added here so children can override emit and still call the base functionality. See NetworkEventEmitter.emit for example
ExperimentalRuns the subscriptions for the event, keeping each subscriber's failure to itself: a subscriber
that throws hands its error to handleSubscriberError and the remaining subscribers still
run.
Use this where the emit is the only time subscribers are told about something that has already happened and will not be reported again — one broken subscriber must not cost the rest the news. Prefer emit everywhere else: a caller that can still act on a throw should see it.
This does not await async subscribers. It routes their rejections — a subscriber whose
promise rejects reaches handleSubscriberError the same way a synchronous throw does — but it
does not sequence them: this returns as soon as every subscriber has been started, with any
async subscriber still suspended at its first await. An emitter that tears something down
right after emitting therefore tears it down out from under those subscribers.
Event data to provide to subscribed callbacks
Run with the error a subscriber threw and that subscriber's position in the subscription order. Must not throw; a throw from it stops the remaining subscribers, which is the very thing this is here to prevent.
ProtectedemitExperimentalFunction that runs the subscriptions for the event in isolation from each other. Added here so children can override emitIsolated and still call the base functionality.
Event manager - accepts subscriptions to an event and runs the subscription callbacks when the event is emitted Use eventEmitter.event(callback) to subscribe to the event. Use eventEmitter.emit(event) to run the subscriptions. Generally, this EventEmitter should be private, and its event should be public. That way, the emitter is not publicized, but anyone can subscribe to the event.