API Docs for: v2.1.0
Show:

CGSGEventManager Class

Extends CGSGObject
Module: Collision

This class manages the association of handler for a particular event which can occurs on a particular object. After an handler is bound to an event, it can be fire thanks to this manager too.

Methods

_getHandlerPropertyName

(
  • eventName
)
String private

Returns the name of a property to create on an object to store additional handlers.

Parameters:

  • eventName Object

    String the event name

Returns:

String:

the attribute name

bindHandler

(
  • observable
  • eventName
  • handler
)
CGSGBindEntry

Binds an handler function for an event which can occurs on a given observable object.

Parameters:

  • observable Object

    the observable object

  • eventName String

    The event's name

  • handler Function

    the handler

Returns:

CGSGBindEntry:

the ID of the binding

dispatch

(
  • observable
  • eventName
  • event
)

Notifies an event to all handlers bound to the given event on the given observable object. For performance reasons, this method must not be called if no handler is bound to the observable. Consequently, for instance, if you have an event 'onClick' that you want to dispatch, wrap the call in an if statement like this (otherwise the execution will fail) : if (this.onClick) { CGSG.eventManager.dispatch(...); }

Parameters:

  • observable Object

    the observable object

  • eventName String

    The event's name

  • event CGSGEvent

    the event to notify

replaceHandler

(
  • key
  • handler
)

Replaces the handler associated to the given key by the new specified handler.

Parameters:

unbindAll

(
  • observable
  • eventName
)

Unbinds all handlers registered for an event on a given object.

Parameters:

  • observable Object

    the observable object

  • eventName String

    The event's name

unbindHandler

(
  • observable
  • eventName
  • handler
)

Unbind an handler registered for an event on an object.

Parameters:

  • observable Object

    the observable object

  • eventName String

    The event's name

  • handler Function

    the handler