Sha256: f5a7ca5ec3cf70da223f2d2c2d6515f4151d126b8524f754778d4720f6b56292

Contents?: true

Size: 891 Bytes

Versions: 33

Compression:

Stored size: 891 Bytes

Contents

module Startback
  class Event
    class Bus
      module Memory
        #
        # Synchronous implementation of the Bus abstraction, for use between
        # components sharing the same process.
        #
        class Sync
          include Support::Robustness

          def initialize
            @listeners = {}
          end

          def connect
          end

          def emit(event)
            (@listeners[event.type.to_s] || []).each do |l|
              l.call(event)
            end
          end

          def listen(type, processor = nil, listener = nil, &bl)
            raise ArgumentError, "A listener must be provided" unless listener || bl
            @listeners[type.to_s] ||= []
            @listeners[type.to_s] << (listener || bl)
          end

        end # class Sync
      end # module Memory
    end # class Bus
  end # class Event
end # module Startback

Version data entries

33 entries across 33 versions & 3 rubygems

Version Path
startback-1.0.1 lib/startback/event/bus/memory/sync.rb
startback-1.0.0 lib/startback/event/bus/memory/sync.rb
startback-0.19.4 lib/startback/event/bus/memory/sync.rb
startback-0.19.3 lib/startback/event/bus/memory/sync.rb
startback-0.19.1 lib/startback/event/bus/memory/sync.rb
startback-0.19.0 lib/startback/event/bus/memory/sync.rb
startback-0.18.2 lib/startback/event/bus/memory/sync.rb
startback-0.18.1 lib/startback/event/bus/memory/sync.rb
startback-0.18.0 lib/startback/event/bus/memory/sync.rb
startback-0.17.4 lib/startback/event/bus/memory/sync.rb
startback-0.17.3 lib/startback/event/bus/memory/sync.rb
startback-0.17.2 lib/startback/event/bus/memory/sync.rb
startback-0.17.1 lib/startback/event/bus/memory/sync.rb
startback-0.17.0 lib/startback/event/bus/memory/sync.rb
startback-0.16.0 lib/startback/event/bus/memory/sync.rb
startback-0.15.5 lib/startback/event/bus/memory/sync.rb
startback-0.15.4 lib/startback/event/bus/memory/sync.rb
startback-0.15.3 lib/startback/event/bus/memory/sync.rb
startback-0.15.2 lib/startback/event/bus/memory/sync.rb
startback-0.15.1 lib/startback/event/bus/memory/sync.rb