Show:

JSUTILS.EventDispatcher Class

The EventDispatcher class mimics the DOM event dispatcher model so the user can add and remove event listeners in a familiar way. Event bubbling is not available because events are dispatched in relation to state changes of physical components instead of layered graphics so there is nothing to bubble up.

Constructor

JSUTILS.EventDispatcher

(
  • target
)

Parameters:

  • target Class

    The instance of the class that implements EventDispatcher

Methods

addEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The function to be called when the event is fired

dispatchEvent

(
  • type
  • optionalParams
)

Parameters:

  • type Event

    The Event object.

  • optionalParams Object

    Optional parameters passed as an object. return {boolean} True if dispatch is successful, false if not.

hasEventListener

(
  • type
)

Parameters:

  • type String

    The event type return {boolean} True is listener exists for this type, false if not.

removeEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The function to be called when the event is fired