Namespace: Events

Responsiville. Events

Special scope which contains functions that may be injected in any object's prototype so that it is extended with event mechanisms (event register, deregister, fire). Not meant to be used autonomously.

Methods

staticResponsiville.Events.deregisterEvent(eventName){void}

Deregisters an event in the scope of the calling object. Simply makes the object no longer aware of that particular event and cleans its structures.
Name Type Description
eventName String The name of the event to deregister.
Returns:
Type Description
void

staticResponsiville.Events.fireEvent(eventName, args){void}

Calls all the callbacks registered on the given event on the calling object. The callback will be called in the scope of that object.
Name Type Description
eventName String The name of the event whose callbacks are to be called.
args array Array of argument values to pass to the callback functions when they are called. It is up to the callback function to know what these arguments are and how to use them in runtime.
Returns:
Type Description
void

staticResponsiville.Events.getBoundFunction(theFunction){void}

Takes a function, binds it in the scope of the current object and returns the bound function. If the same function has been bound to the current object before, then that bound instance is returned and no new bound function is created. Useful when registering and deregistering bound functions to the Responsiville framework's events where you do not want to register the same bound function to an event twice by accident.
Name Type Description
theFunction function The function to bind to the current object scope.
Returns:
Type Description
void

staticResponsiville.Events.off(eventName, callback){void}

Deregisters a callback function from being called when the event is fired on the calling object.
Name Type Description
eventName String The name of the event in which to detach the callback function.
callback function The callback function to detach to the event.
Returns:
Type Description
void

staticResponsiville.Events.on(eventName, callback){void}

Registers a callback function to be called when an event is fired on the calling object inside the scope of the object.
Name Type Description
eventName String The name of the event in which to attach the callback function.
callback function The callback function to attach to the event.
Returns:
Type Description
void

staticResponsiville.Events.registerEvent(eventName){void}

Registers an event in the scope of the calling object. Simply makes the object aware of that particular event and prepares its structures.
Name Type Description
eventName String The name of the event to register.
Returns:
Type Description
void