getEvents()
The getEvents() function (client-side) handles a group of synchronous events together to retrieve, monitor, and act on several events at the same time.
Syntax
Use this syntax for the getEvents() function:
var events = getEvents(['eventName1','eventName2', 'eventNamen']);
Return Value
The getEvents() function returns an object representing the specified events. This object includes the name property, which corresponds to the event names provided to the function. The object also exposes several methods to handle event resolution, failure, and listeners.
|
Method |
Description |
|---|---|
|
|
Invokes the callback when any or all listed events resolve. The callback is attached to each event. |
|
|
Attaches the callback as a failure handler to all underlying events. |
|
|
Invokes |
|
|
Invokes |
|
|
If the verified condition returns |
|
|
Registers the callback to run after all events are resolved or rejected. |
Parameters
The getEvents() function accepts an array of strings representing the event names as a required parameter.
Examples
The following examples show how to use the getEvents() function.
Attaching a Listener to All Events in a Group
This example groups multiple events and runs a function when the specified events finish. The callback runs after all relevant events are resolved.
var events = getEvents(['floor.ready', 'canvas.ready']);
events.then(function(data){
console.log('Floor and canvas are ready.');
});