Class: Aws::EventEmitter
- Inherits:
-
Object
- Object
- Aws::EventEmitter
- Defined in:
- lib/aws-sdk-core/event_emitter.rb
Instance Method Summary collapse
-
#initialize ⇒ EventEmitter
constructor
A new instance of EventEmitter.
- #on(type, callback) ⇒ Object
- #signal(type, event) ⇒ Object
Constructor Details
#initialize ⇒ EventEmitter
Returns a new instance of EventEmitter.
4 5 6 |
# File 'lib/aws-sdk-core/event_emitter.rb', line 4 def initialize @listeners = {} end |
Instance Method Details
#on(type, callback) ⇒ Object
8 9 10 |
# File 'lib/aws-sdk-core/event_emitter.rb', line 8 def on(type, callback) (@listeners[type] ||= []) << callback end |
#signal(type, event) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/aws-sdk-core/event_emitter.rb', line 12 def signal(type, event) return unless @listeners[type] @listeners[type].each do |listener| listener.call(event) if event.event_type == type end end |