top

CAPH.DAL.EVENTHANDLER

EventHandler is a class that deals with event handling of data loaders, which include BaseLoader, Preloader, TagLoader and XHRLoader. With EventHandler, a user can subscribe to an event, unsubscribe an event and trigger an event. EventHandler supports several event listeners on a single event type.


Constructor

EventHandler

Description
Construct a EventHandler
Emulator SupportY
SDK ConstraintNone
Example
var EventHandler = caph.dal.EventHandler
var eventhandler = new EventHandler();

Methods

EventHandler

Description
(Constructor) Construct a EventHandler
Parameters
■Void
Return■EventHandler
  - Instance of EventHandler
Emulator SupportY
SDK Constraintnone
Example
var EventHandler = caph.dal.EventHandler
var eventhandler = new EventHandler();

subscribe

Description
Subscribe to an event
Parameters
■typeString
  - String 
  - type string of an event
  - [default : null]
■callback: 
  - Function
  - A callback function to be called
  - [default : null]
Return■Object
  - The instance itself.
Emulator SupportY
SDK Constraintnone
Example
var EventHandler = caph.dal.EventHandler
var eventhandler = new EventHandler();

function foo() {
    console.log('in function foo');
}

eventhandler.subscribe('onprogress', foo);
eventhandler.publish('onprogress', window, 'foofoo');

publish

Description
Publish an event
Parameters
■typeString
  - String 
  - type string of an event
  - [default : null]
■callbackThis
  - Any
  - A callback parameter to be transferred as this
  - [default : null]
■callbackData:  
  - Any
  - A callback parameter to be transferred as data
  - [default : null]
Return■Void
Emulator SupportY
SDK Constraintnone
Example
var EventHandler = caph.dal.EventHandler
var eventhandler = new EventHandler();

function foo() {
    console.log('in function foo');
}

eventhandler.subscribe('onprogress', foo);
eventhandler.publish('onprogress', window, 'foofoo');

unsubscribe

Description
Unsubscribe to an event
Parameters
■typeString
  - String 
  - type string of an event
  - [default : null]
■callback: 
  - Function
  - A callback function to be called
  - [default : null]
Return■Void
Emulator SupportY
SDK Constraintnone
Example
var EventHandler = caph.dal.EventHandler
var eventhandler = new EventHandler();

function foo() {
    console.log('in function foo');
}

eventhandler.subscribe('onprogress', foo);
eventhandler.publish('onprogress', window, 'foofoo');
eventhandler.unsubscribe('onprogress', foo);