Autodesk Creative Platform Core Version 1.19.0
A broad and deep collection of 2D and 3D capabilities.

EventSource Overview

EventSource is the standard way of declaring an event which clients can bind to, to receive callback notifications when the event occurs.

Introduced in Version: 1.1.0

1 Example:

//define custom event to which listeners can listen for a change
var customEvent = new CoreLibrary.EventSource('customevent');

var eventListener = function () {
    //some code
};

customEvent.bind(eventListener); //bind event listener

function someFunction() {
    customEvent.fire(); //call all the event listeners
    
    //unbind listener
    customEvent.unbind(eventListener);
}

Class Member Summary

Class Member Details

• EventSource (type, [target]) | Constructor

The following parameters can be specified in the constructor:
  • type: String - A meaningful identifier for the event name.
  • target: Object - The object that serves as the {Event#target} for raised events. | Optional

• bind (listener)

Bind listener function to specific event.
  • listener: Function - Listener function

1 Example:

    event.bind(listener);

• fire (data, originalEvent)

Will invoke all the listener functions.
  • data: Object - Event-specific data that will be available on the Event object in the data field.
  • originalEvent: Object - Originating event, if this event is caused by another event. Will be available on the Event object in the originalEvent field.

1 Example:

    event.fire(value);
    event.fire(value, domEvent);

• unbind (listener)

Unbind listener function from specific event.
  • listener: Function - Listener function

2 Examples:

    event.unbind(); //will unbind all the listeners
    event.unbind(listener); //will unbind specific listener