Class: Aws::EventEmitter

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-core/event_emitter.rb

Instance Method Summary collapse

Constructor Details

#initializeEventEmitter

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