Mixin for objects that need to bind to events from a source object,
and wish to handle events with member functions.
- Source:
Methods
-
<static> getBoundMethodName(methodName) → {String}
-
Creates a method name to use for binding a member event handler function to the target instance. E.g. if your target has a method named "onItemChanged", this method will return a new function name like "_bound_onItemChanged" which can be used as a new member name to store the bound member function.
Parameters:
Name Type Description methodName
String method name to prefix - Source:
Returns:
prefixed method name- Type
- String
-
bindEvents(source, eventToMethodMap) → {undefined}
-
Binds events from the source object to a handler method on 'this' object. The handler method is automatically bound to 'this', and stored on 'this' using a prefixed method name, based on the original method name.
Parameters:
Name Type Description source
* object which emits an event, and can be subscribed to. eventToMethodMap
Object hash of event name to method name of this. - Source:
Returns:
- Type
- undefined
-
getEventNames(eventName) → {String[]}
-
Splits an event name by " " into possibly multiple event names
Parameters:
Name Type Description eventName
String single or space-delimited event name(s) - Source:
Returns:
- array of event names- Type
- String[]
-
getOffMethodName(source) → {String}
-
Tries to find a method on the source object which can be used to unbind events.
Parameters:
Name Type Description source
* object which emits events - Source:
Returns:
first method name that could be used to unbind events.- Type
- String
-
getOnMethodName(source) → {String}
-
Tries to find a method on the source object which can be used to bind events.
Parameters:
Name Type Description source
* object that emits events - Source:
Returns:
first method name that could be used to bind events.- Type
- String
-
unbindEvents(source, eventToMethodMap) → {undefined}
-
Unbinds from events from a given source object, which were previously bound using bindEvents.
Parameters:
Name Type Description source
* source object that emits events eventToMethodMap
Object hash of event names to method names of 'this' - Source:
Returns:
- Type
- undefined