Class EventEmitter
Constructor Attributes | Constructor Name and Description |
---|---|
A base support class for emitting events, based on the
Event Emitter class from node.js.
|
Method Attributes | Method Name and Description |
---|---|
addListener(type, listener, once)
Add a listener which will be called back.
|
|
emit(type, args)
Emit an event of a specific type.
|
|
on(type, listener, {once=false})
Add a listener to this event emitter.
|
|
once(type, listener)
Adds a one time listener for the
Event . |
|
removeAllListeners(type)
Removes all the listeners that are listening for a specific type
of event.
|
|
removeListener(type, listener)
Stops a specified listener from receiving further events.
|
Class Detail
EventEmitter()
A base support class for emitting events, based on the
Event Emitter class from node.js.
It supports registering event listeners for any type of event and later emitting events to
those listeners that registered for a specific type of event.
Typically, users of Content Studio would only use the instances of a class that are
provided by Content Studio, such as an action or the Content Studio instance. And the
most common thing to do would be to register (or deregister) event listeners.
CS.on('some-event', function(args) { // do something. });
Method Detail
addListener(type, listener, once)
Add a listener which will be called back. An alias for the
on()
function.
- Parameters:
- type
- listener
- once
emit(type, args)
Emit an event of a specific type. This will notify (invoke) each of the
listeners in order with any the given arguments.
- Parameters:
- {String} type
- The type of event to emit
- args
- Any additional arguments that should be passed to the listeners
on(type, listener, {once=false})
Add a listener to this event emitter. The listener will be called back
the next time someone emits an event of the type specified by the
type
parameter.
- Parameters:
- {String} type
- the type of events the listener is interested in
- {Function} listener
- the callback function that will be invoked when the event is emitted
- {Boolean} {once=false}
- true if the listener should only be notified for the first event, false if the listener should be notified for all events.
once(type, listener)
Adds a one time listener for the
Event
. This listener is
invoked only the next time the event is fired, after which it is removed.
myemitter.once('something', function() { // will be called only for the first event });
- Parameters:
- {String} type
- - type of the listener.
- {Function} listener
- - the listener
removeAllListeners(type)
Removes all the listeners that are listening for a specific type
of event. Care should be taken not to disrupt other plug-ins
when calling this on shared event emitters that you do not control
yourself, for example the ones provided by Content Studio.
- Parameters:
- {String} type
- the type of events that all listeners should be removed.
removeListener(type, listener)
Stops a specified listener from receiving further events.
- Parameters:
- {String} type
- type of the listener
- {Function} listener
- the listener