Sha256: 4bd65c7da9518215e51ec59f400303a6f5bc29d26a828599e37dbdf2ff4fd885
Contents?: true
Size: 1.02 KB
Versions: 31
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module Aws class EventEmitter def initialize @listeners = {} @validate_event = true @signal_queue = Queue.new end attr_accessor :stream attr_accessor :encoder attr_accessor :validate_event attr_accessor :signal_queue def on(type, callback) (@listeners[type] ||= []) << callback end def signal(type, event) return unless @listeners[type] @listeners[type].each do |listener| listener.call(event) if event.event_type == type end end def emit(type, params) unless @stream raise Aws::Errors::SignalEventError.new( "Singaling events before making async request"\ " is not allowed." ) end if @validate_event && type != :end_stream Aws::ParamValidator.validate!( @encoder.rules.shape.member(type), params) end @stream.data( @encoder.encode(type, params), end_stream: type == :end_stream ) end end end
Version data entries
31 entries across 31 versions & 1 rubygems