Skip to content

Emitter

An emitter that can be used to emit events, this class will be used to push updates from the Discord Websockets out to the Consumers of this library.

Properties

The Emitter instance has no set properties!

Methods

The Emitter instance has no set methods!

Functions

listen

Emitter . listen (

     self: Emitter<T...>
     callback: (T...) -> ()
)  -> ()

Listen to this event, returns a function that can be called to disconnect the listener

listenOnce

Emitter . listenOnce (

     self: Emitter<T...>
     callback: (T...) -> ()
)  -> ()

Listen to this event once, this will automatically disconnect after the first invocation

wait

Emitter . wait (

     self: Emitter<T...>
)  -> ()

Wait for this event to be emitted from, returns the result of the emittion

invoke

Emitter . invoke (

     self: Emitter<T...>
     ...: any
)  -> ()

Responsible for invoking all the threads that are listening to this emitter.

This will additionally resume all the threads that are currently waiting for an event to be emitted.

new

Emitter . new ()  -> ()

Constructor for the Emitter object, will return a new instance of the Emitter object.