Registers a listener for an event. The Frame API calls the specified handler when the event fires. If your component is hosted inside an iFrame, to prevent memory leaks and possible bugs, ensure your component calls removeListener in its window.unload() event.
addListener(String eventName, Function handler, Object scope, Object options) : void
- eventName – The name of the event to listen for. Specify any of the Frame API event names or any names added with addEvent.
- handler – Function that the event invokes. The parameters passed to the handler depends on the event being fired.
- scope – Optional scope (this pointer) in which the handler function executes. If omitted, scope defaults to the Frame API object.
- options – An optional object containing handler configuration. This may contain any of the following properties:
|delay||Number||(Optional) The number of milliseconds to delay the invocation of the handler after the event fires.|
|single||Boolean||(Optional) True to add a handler to handle just the next firing of the event, and then remove itself.|
|buffer||Number||(Optional) – Causes the handler to be scheduled to run delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.|