Emitter - truemedian/Discordia GitHub Wiki
Implements an asynchronous event emitter where callbacks can be subscribed to specific named events. When events are emitted, the callbacks are called in the order that they were originally registered.
on
once
onSync
onceSync
emit
getListeners
getListenerCount
removeListener
removeAllListeners
waitFor
Subscribes a callback to be called every time the named event is emitted. Callbacks registered with this method will automatically be wrapped as a new coroutine when they are called. Returns the original callback for convenience.
Name Type name string fn function Returns: function
Subscribes a callback to be called only the first time this event is emitted. Callbacks registered with this method will automatically be wrapped as a new coroutine when they are called. Returns the original callback for convenience.
Name Type name string fn function Returns: function
Subscribes a callback to be called every time the named event is emitted. Callbacks registered with this method are not automatically wrapped as a coroutine. Returns the original callback for convenience.
Name Type name string fn function Returns: function
Subscribes a callback to be called only the first time this event is emitted. Callbacks registered with this method are not automatically wrapped as a coroutine. Returns the original callback for convenience.
Name Type name string fn function Returns: function
Emits the named event and a variable number of arguments to pass to the event callbacks.
Name Type Optional name string ... * x Returns: nil
Returns an iterator for all callbacks registered to the named event.
Name Type name string Returns: function
Returns the number of callbacks registered to the named event.
Name Type name string Returns: number
Unregisters all instances of the callback from the named event.
Name Type name string Returns: nil
Unregisters all callbacks from the named event.
Name Type name string Returns: nil
When called inside of a coroutine, this will yield the coroutine until the specific named event is emitted or until a timeout (in milliseconds) expires. If the coroutine is resumed by the event, then
true
is returned with any event arguments. If the coroutine is resumed by the timeout's expiration, thenfalse
is returned without any other arguments.
Name Type Optional Optional name string timeout number x predicate function x Returns: boolean, ...