AsyncEventEmitter class

Implementation of a typed async event emitter. This event emitter maintains a queue of events, the events are processed in order and the next is not started until all (async) event listeners for the previous event have finished. Event listers for a single event are processed concurrently, events are processed sequentially. Typings are inspired by the 'typed-emitter' package.

Constructors

AsyncEventEmitter()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(String event, Handler listener) AsyncEventEmitter
Adds the listener function to the end of the listeners array for the given event. The listeners will be called in order but if they are asynchronous they may run concurrently. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of event and listener will result in the listener being added, and called, multiple times. @param event The event to add the listener to. @param listener The listener to add. @returns A reference to the AsyncEventEmitter, so that calls can be chained.
enqueueEmit<Arg>(String event, Arg arg) → void
Enqueues an event to be processed by its listeners. Calls each of the listeners registered for the event named event in order. If several asynchronous listeners are registered for this event, they may run concurrently. However, all (asynchronous) listeners are guaranteed to execute before the next event is processed. If the error event is emitted and the emitter does not have at least one listener registered for it, the error is thrown. @param event The event to emit. @param args The arguments to pass to the listeners.
eventNames() List<String>
@returns An array listing the events for which the emitter has registered listeners.
getMaxListeners() int
listenerCount(String event) int
@returns The number of listeners associated to the given event.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
off(String event, Handler listener) AsyncEventEmitter
Alias for removeListener.
on(String event, Handler listener) AsyncEventEmitter
once(String event, Handler listener) AsyncEventEmitter
Adds a listener that is only called on the first event.
prependListener(String event, Handler listener) AsyncEventEmitter
Adds the listener function to the beginning of the listeners array for the given event. The listeners will be called in order but if they are asynchronous they may run concurrently. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of event and listener will result in the listener being added, and called, multiple times. @param event The event to prepend the listener to. @param listener The listener to prepend. @returns A reference to the AsyncEventEmitter, so that calls can be chained.
prependOnceListener(String event, Handler listener) AsyncEventEmitter
Adds a one-time listener function for the given event to the beginning of the listeners array. The next time the event is triggered, this listener is removed, and then invoked. @param event The event to prepend the listener to. @param listener The listener to prepend. @returns A reference to the AsyncEventEmitter, so that calls can be chained.
removeAllListeners(String? event) AsyncEventEmitter
Removes all listeners, or those of the specified event. @param event The event for which to remove all listeners. @returns A reference to the AsyncEventEmitter, so that calls can be chained.
removeListener(String event, Handler listener) AsyncEventEmitter
Removes the given event listener. @param event The event for which to remove a listener. @param listener The listener to remove. @returns A reference to the event emitter such that calls can be chained.
setMaxListeners(int maxListeners) AsyncEventEmitter
By default AsyncEventEmitters print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. This method modifies the limit for this specific AsyncEventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners. @param maxListeners @returns A reference to the event emitter, so that calls can be chained.
toString() String
A string representation of this object.
inherited
waitForProcessing() Future<void>
Wait for event queue to finish processing.

Operators

operator ==(Object other) bool
The equality operator.
inherited