ArgumentPassingMode
is the argument passing mode.
The possible values,
EventDispatcher.argumentPassingIncludeEvent = ArgumentPassingMode.IncludeEvent;
EventDispatcher.argumentPassingExcludeEvent = ArgumentPassingMode.ExcludeEvent;
The global default value,
EventDispatcher.defaultArgumentPassingMode = ArgumentPassingMode.ExcludeEvent;
Let's see some examples. Assume we have the dispatcher
let dispatcher = new EventDispatcher();
// same as
let dispatcher = new EventDispatcher({ argumentPassingMode: EventDispatcher.argumentPassingExcludeEvent });
dispatcher.dispatch(3, "hello");
The listener will be invoked with the argument ("hello")
, the event type is omitted since it's argumentPassingExcludeEvent.
argumentsAsArray
affects how the listeners and getEvent
receive the arguments.
When argumentsAsArray
is false, the listeners and getEvent
receive the arguments as individual parameters. For example,
let dispatcher = new EventDispatcher();
// same as
let dispatcher = new EventDispatcher({ argumentsAsArray: false });
dispatcher.dispatch(a, b, c);
// The listener will be called as
myListener(a, b, c);
When argumentsAsArray
is true, the listeners and getEvent
receive the arguments as an array of which each elements are the arguments. For example,
let dispatcher = new EventDispatcher({ argumentsAsArray: true });
dispatcher.dispatch(a, b, c);
// The listener will be called as
myListener([ a, b, c ]);
Setting argumentsAsArray
to true will slightly improve the performance.
canContinueInvoking(arg1, arg2, ...)
. The function receives same arguments as EventDispatcher.dispatch and EventQueue.enqueue, and must return true if the event dispatching or callback list invoking can continue, false if the dispatching should stop.
The function receives same arguments as EventDispatcher.dispatch and EventQueue.enqueue, and must return an event type.
quick-event forwards all arguments of EventDispatcher.dispatch and EventQueue.enqueue (both has same arguments) to getEvent to get the event type, then invokes the callback list of the event type.
A mixin is used to inject code in the EventDispatcher/EventQueue inheritance hierarchy to extend the functionalities. For more details, please read the document of mixins.
Generated using TypeDoc
All classes CallbackList, EventDispatcher and EventQueue in quick-event accepts a parameters object in constructor to configure and extend each components' behavior. The parameters object is
undefined
by default.All parameters are optional. If any parameter is omitted, the default value is used.
The same parameter mechanism applies to all three classes, CallbackList, EventDispatcher and EventQueue, though not all classes requires the same parameter.
QuickEventParams