Package com.brightcove.player.event
Interface EventEmitter
- All Known Implementing Classes:
EventEmitterImpl
,RegisteringEventEmitter
public interface EventEmitter
Defines the public facing api for classes that wish to emit
events. See EventEmitterImpl for the main implementation method
descriptions.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
disable()
Disables listener registration and event emitting.void
Emits an Event.void
Emits an event with a dynamic properties Map.void
Emits an event immediately instead of waiting for the handler.void
enable()
Enables listener registration and event emitting.void
off()
De-register all listeners.void
Unregister a listener from listening to an event type.int
on
(String eventType, EventListener listener) Register an event listener to be called when an EventType is emitted.int
once
(String eventType, EventListener listener) Similar to on, except that the listener will be removed after processing one event.void
request
(String eventType, EventListener listener) Requests a response from the first listener to respond.void
Request a response from the first listener to respond.void
Respond to a request.void
Respond to a request.
-
Method Details
-
on
Register an event listener to be called when an EventType is emitted.- Parameters:
eventType
-listener
-- Returns:
- a unique token that can be used to unregister the listener.
- See Also:
-
once
Similar to on, except that the listener will be removed after processing one event.- Parameters:
eventType
-listener
-- Returns:
- A token, which can be used later to turn the listener off.
- See Also:
-
off
void off()De-register all listeners. -
off
Unregister a listener from listening to an event type. Uses a unique token to identify which listener to remove.- Parameters:
eventType
-token
-
-
emit
Emits an Event.- Parameters:
eventType
-
-
emit
Emits an event with a dynamic properties Map.- Parameters:
eventType
-properties
-
-
emitNow
Emits an event immediately instead of waiting for the handler.- Parameters:
eventType
- The event type.properties
- The properties to send when processing the event.
-
request
Requests a response from the first listener to respond. The response is handled by the provided listener, after which the listener is removed.- Parameters:
eventType
- The type of Event to emit and expect a response from.listener
- A listener to process the response. After processing, the response should be removed.- See Also:
-
request
Request a response from the first listener to respond. The response is handled by the provided listener, after which the listener is removed. The provided properties map is passed on to the responding listener- Parameters:
eventType
- The type of Event to emit and expect a response from.properties
- A Map of properties to pass along the event chainlistener
- A listener to process the response. After processing, the response should be removed- See Also:
-
respond
Respond to a request. Should be placed within an EventListener and via some means (e.g. the token of an InvocationContainer) know which Request Listener to respond to.- Parameters:
properties
-
-
respond
Respond to a request. Should be called within an EventListener and given an Event object with the appropriate REQUEST_TOKEN value.- Parameters:
event
- An Event object with, at minimum, the necessary REQUEST_TOKEN value
-
enable
void enable()Enables listener registration and event emitting. -
disable
void disable()Disables listener registration and event emitting.
-