Component_EventEmitter Class
A component which allow a game object to fire events and manage a list of observers.
Item Index
Methods
Properties
Methods
checkForHandlerFunction
-
eventName
-
handlerFunction
Checks if an event-handler with a specified handler-function exists for the given event.
Parameters:
-
eventName
String- The event name.
-
handlerFunction
Function- The handler-function to search for.
Returns:
If true, an observer witht he specified handler-function exists for the given event. Otherwise false.
checkForOwner
-
eventName
-
owner
Checks if an event-handler with a specified owner exists for the given event.
Parameters:
-
eventName
String- The event name.
-
owner
Function- The owner to search for.
Returns:
If true, an event-handler with the specified owner exists for the given event. Otherwise false.
clear
()
Clears the event emitter by removing all handlers/listeners.
emit
-
eventName
-
[sender=null]
-
[data={}]
Emits the specified event. All observers/listeners registered for the specified event are informed.
Parameters:
-
eventName
String- The name of the event to fire.
-
[sender=null]
Object optional- The sender of the event.
-
[data={}]
Object optional- An optional object passed to each handler-function.
off
-
eventName
-
[handler=null]
Removes an observer/listener from a specified event. If handler parameter is null, all observers for the specified event are removed.
Parameters:
-
eventName
String- The event name.
-
[handler=null]
gs.EventObserver optional- The observer-object to remove. If null, all observers for the specified event are removed.
offByOwner
-
eventName
-
owner
Removes all observers/listeners from an event which are belonging to the specified owner.
Parameters:
-
eventName
String- The event name.
-
owner
Object- The owner.
Returns:
Count of removed observers/listeners.
on
-
eventName
-
handler
-
[data={}]
-
[owner=null]
-
priority
Adds a new observer/listener for a specified event.
Parameters:
-
eventName
String- The event name.
-
handler
Function- The handler-function called when the event is fired.
-
[data={}]
Object optional- An optional info-object passed to the handler-function.
-
[owner=null]
Object optional- An optional owner-object associated with the observer/listener.
-
priority
Number- An optional priority level. An observer/listener with a higher level will receive the event before observers/listeners with a lower level.
Returns:
- The added observer-object.
once
-
eventName
-
handler
-
[data={}]
-
[owner=null]
-
priority
Adds a new observer/listener for a specified event and removes it after the even has been emitted once.
Parameters:
-
eventName
String- The event name.
-
handler
Function- The handler-function called when the event is fired.
-
[data={}]
Object optional- An optional info-object passed to the handler-function.
-
[owner=null]
Object optional- An optional owner-object associated with the observer/listener.
-
priority
Number- An optional priority level. An observer/listener with a higher level will receive the event before observers/listeners with a lower level.
Returns:
- The added observer-object.
onDataBundleRestore.
-
Object
-
gs.ObjectCodecContext
Called if this object instance is restored from a data-bundle. It can be used re-assign event-handler, anonymous functions, etc.
Parameters:
-
Object
Objectdata - The data-bundle
-
gs.ObjectCodecContext
Objectcontext - The codec-context.
update
()
Not implemented yet.
Properties
chainInfo
Object
private
defaultData
Object
private
handlers
Object
private
List of registered observers.