Events Manager
(eventsManager)
Overview
This is the EventsManager where you can register for events that are fired by the servoy for the default events and custom events can be listened to and fired for in code.
The EventType can be a build in one or custom one that are set in the solution/module eventTypes property.
Returned Types
Methods Summarized
void
Adds a listener for a custom EventType or for one of default event types.
void
Adds a listener for a custom EventType or for one of default event types.
Calls all listeners for a certain event type Will return a Boolean calculated as logical AND between all listeners return value (default value).
Calls all listeners for a certain event type and for a certain context).
Calls all listeners for a certain event type and certain context.
Calls all listeners for a certain event type (and optionally, for a certain context).
Calls all listeners for a certain event type Will return a Boolean calculated as logical AND between all listeners return value (default value).
Checks if listeners were added for a certain event type (and possibly context)
void
Removes one or multiple listeners (depending on parameters).
Methods Detailed
addEventListener(eventType, callback)
Adds a listener for a custom EventType or for one of default event types. The custom event is defined on solution eventType property and can be fired using fireEventListeners.
The callback first parameter is always a JSEvent object. The source is the context (for default form event types this is 'forms.MyForm') also the formName is set to the form that triggered this for the default events. The data object of the JSEven object is the argument array, those are also given as parameters after the first JSEvent parameter. For default types these are the same arguments then what the forms event function also would get (so that could also containe a JSEvent parameter) For custom types the given arguments in the fireEventListeners call are given as parameters after the JSEvent parameter and as Array in the data object of the JSEvent object
Parameters
Returns: void
Sample
addEventListener(eventType, callback, context)
Adds a listener for a custom EventType or for one of default event types. The custom event is defined on solution eventType property and can be fired using fireEventListeners. When context is specified, the callback will only be called on that context: for custom events, when fireEventListeners is called using same context and for default events when context is the specific form that triggers the default form event.
The callback first parameter is always a JSEvent object. The source is the context (for default form event types this is 'forms.MyForm') also the formName is set to the form that triggered this for the default events. The data object of the JSEven object is the argument array, those are also given as parameters after the first JSEvent parameter. For default types these are the same arguments then what the forms event function also would get (so that could also containe a JSEvent parameter) For custom types the given arguments in the fireEventListeners call are given as parameters after the JSEvent parameter and as Array in the data object of the JSEvent object
Parameters
EventType eventType Event type to listen to.
Function callback callback to be called.
Object context Can be a form, global scope or any string. Will cause callback to only be called on that context.
Returns: void
Sample
fireEventListeners(eventType)
Calls all listeners for a certain event type Will return a Boolean calculated as logical AND between all listeners return value (default value).
Parameters
EventType eventType Event type for listeners to be called.
Returns: Object Boolean value that is a logical AND between all listeners return value.
Sample
fireEventListeners(eventType, context)
Calls all listeners for a certain event type and for a certain context). Will return a Boolean calculated as logical AND between all listeners return value (default value).
Parameters
EventType eventType Event type for listeners to be called.
Object context Context for listeners to be called. Can be null (any context).
Returns: Object Boolean value that is a logical AND between all listeners return value.
Sample
fireEventListeners(eventType, context, callbackArguments)
Calls all listeners for a certain event type and certain context. Will return a Boolean calculated as logical AND between all listeners return value (default value).
Parameters
EventType eventType Event type for listeners to be called.
Object context Context for listeners to be called. Can be null (any context).
Array callbackArguments Arguments for listener to be called with. Can be null.
Returns: Object Boolean value that is a logical AND between all listeners return value.
Sample
fireEventListeners(eventType, context, callbackArguments, returnValueAggregationType)
Calls all listeners for a certain event type (and optionally, for a certain context). Will return either a Boolean calculated as logical AND between all listeners return value or an Array with all return values.
Parameters
EventType eventType Event type for listeners to be called.
Object context Context for listeners to be called. Can be null (any context).
Array callbackArguments Arguments for listener to be called with. Can be null.
enum returnValueAggregationType Return value constant. Should be taken from EVENTS_AGGREGATION_TYPE.
Returns: Object Boolean or Array depending on returnValueAggregationType. Boolean value is a logical AND between all listeners return value and Array contains all return values of the listeners.
Sample
fireEventListeners(eventType, callbackArguments)
Calls all listeners for a certain event type Will return a Boolean calculated as logical AND between all listeners return value (default value).
Parameters
EventType eventType Event type for listeners to be called.
Array callbackArguments Arguments for listener to be called with. Can be null.
Returns: Object Boolean value that is a logical AND between all listeners return value.
Sample
hasEventListeners(eventType, context)
Checks if listeners were added for a certain event type (and possibly context)
Parameters
EventType eventType Event type for listener to check.
Object context Context for listener to check. Can be null (any context).
Returns: Boolean Boolean (true) if listeners were added, (false) otherwise
Sample
removeEventListener(eventType, callback, context)
Removes one or multiple listeners (depending on parameters). Only works for custom event listeners that were added using addEventListener.
Parameters
EventType eventType Event type for listener to remove. Cannot be null.
Function callback callback to be removed. Can be null (any listener).
Object context Context for listener to remove. Can be null (any context).
Returns: void
Sample
Last updated
Was this helpful?