Event.Emitter Class
Extends the Event-instance by adding the method Emitter
to it.
The Emitter-method
returns an object that should be merged into any Class-instance or object you
want to extend with the emit-methods, so the appropriate methods can be invoked on the instance.
Copyright (c) 2014 ITSA - https://github.com/itsa New BSD License - http://choosealicense.com/licenses/bsd-3-clause/
Should be called using the provided extend
-method like this:
Item Index
Methods
defineEvent
-
eventName
Defines a CustomEvent. If the eventtype already exists, it will not be overridden,
unless you force to assign with .forceAssign()
The returned object comes with 4 methods which can be invoked chainable:
- defaultFn() --> the default-function of the event
- preventedFn() --> the function that should be invoked when the event is defaultPrevented
- forceAssign() --> overrides any previous definition
- unHaltable() --> makes the customEvent cannot be halted
- unPreventable() --> makes the customEvent's defaultFn cannot be prevented
- unSilencable() --> makes that emitters cannot make this event to perform silently (using e.silent)
Parameters:
-
eventName
Stringname of the customEvent, without
emitterName
. The final event that will be created has the syntax:emitterName:eventName
, whereemitterName:
is automaticly prepended.
Returns:
with extra methods that can be chained:
- unPreventable() --> makes the customEvent's defaultFn cannot be prevented
- forceAssign() --> overrides any previous definition
- defaultFn() --> the default-function of the event
- preventedFn() --> the function that should be invoked when the event is defaultPrevented
defineEvent
-
eventName
Defines a CustomEvent. If the eventtype already exists, it will not be overridden,
unless you force to assign with .forceAssign()
The returned object comes with 4 methods which can be invoked chainable:
- defaultFn() --> the default-function of the event
- preventedFn() --> the function that should be invoked when the event is defaultPrevented
- forceAssign() --> overrides any previous definition
- unHaltable() --> makes the customEvent cannot be halted
- unPreventable() --> makes the customEvent's defaultFn cannot be prevented
- unSilencable() --> makes that emitters cannot make this event to perform silently (using e.silent)
Parameters:
-
eventName
Stringname of the customEvent, without
emitterName
. The final event that will be created has the syntax:emitterName:eventName
, whereemitterName:
is automaticly prepended.
Returns:
with extra methods that can be chained:
- unPreventable() --> makes the customEvent's defaultFn cannot be prevented
- forceAssign() --> overrides any previous definition
- defaultFn() --> the default-function of the event
- preventedFn() --> the function that should be invoked when the event is defaultPrevented
defineEvent
-
eventName
Defines a CustomEvent. If the eventtype already exists, it will not be overridden,
unless you force to assign with .forceAssign()
The returned object comes with 4 methods which can be invoked chainable:
- defaultFn() --> the default-function of the event
- preventedFn() --> the function that should be invoked when the event is defaultPrevented
- forceAssign() --> overrides any previous definition
- unHaltable() --> makes the customEvent cannot be halted
- unPreventable() --> makes the customEvent's defaultFn cannot be prevented
- unSilencable() --> makes that emitters cannot make this event to perform silently (using e.silent)
Parameters:
-
eventName
Stringname of the customEvent, without
emitterName
. The final event that will be created has the syntax:emitterName:eventName
, whereemitterName:
is automaticly prepended.
Returns:
with extra methods that can be chained:
- unPreventable() --> makes the customEvent's defaultFn cannot be prevented
- forceAssign() --> overrides any previous definition
- defaultFn() --> the default-function of the event
- preventedFn() --> the function that should be invoked when the event is defaultPrevented
emit
-
eventName
-
payload
Emits the event eventName
on behalf of the instance holding this method.
Parameters:
Returns:
- on success: returnValue {Any} of the defaultFn
- on error: reason {Any} Either: description 'event was halted', 'event was defaultPrevented' or the returnvalue of the preventedFn
emit
-
eventName
-
payload
Emits the event eventName
on behalf of the instance holding this method.
Parameters:
Returns:
- on success: returnValue {Any} of the defaultFn
- on error: reason {Any} Either: description 'event was halted', 'event was defaultPrevented' or the returnvalue of the preventedFn
emit
-
eventName
-
payload
Emits the event eventName
on behalf of the instance holding this method.
Parameters:
Returns:
- on success: returnValue {Any} of the defaultFn
- on error: reason {Any} Either: description 'event was halted', 'event was defaultPrevented' or the returnvalue of the preventedFn
undefAllEvents
()
Removes all event-definitions of the instance holding this method.
undefAllEvents
()
Removes all event-definitions of the instance holding this method.
undefAllEvents
()
Removes all event-definitions of the instance holding this method.
undefEvent
-
eventName
Removes the event-definition of the specified customEvent.
Parameters:
-
eventName
Stringname of the customEvent, without
emitterName
. The calculated customEvent which will be undefined, will have the syntax:emitterName:eventName
. whereemitterName:
is automaticly prepended.
undefEvent
-
eventName
Removes the event-definition of the specified customEvent.
Parameters:
-
eventName
Stringname of the customEvent, without
emitterName
. The calculated customEvent which will be undefined, will have the syntax:emitterName:eventName
. whereemitterName:
is automaticly prepended.
undefEvent
-
eventName
Removes the event-definition of the specified customEvent.
Parameters:
-
eventName
Stringname of the customEvent, without
emitterName
. The calculated customEvent which will be undefined, will have the syntax:emitterName:eventName
. whereemitterName:
is automaticly prepended.