Sha256: 19e914e7ee902a0c78cac41191be95dbf2d7d8e7c1f4ca6823902c81a53f8fc4

Contents?: true

Size: 768 Bytes

Versions: 26

Compression:

Stored size: 768 Bytes

Contents

module Startback
  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 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 # module Klaro

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
startback-0.11.5 lib/startback/bus/memory/sync.rb
startback-0.11.4 lib/startback/bus/memory/sync.rb
startback-0.11.3 lib/startback/bus/memory/sync.rb
startback-0.11.0 lib/startback/bus/memory/sync.rb
startback-0.10.1 lib/startback/bus/memory/sync.rb
startback-0.10.0 lib/startback/bus/memory/sync.rb
startback-0.9.1 lib/startback/bus/memory/sync.rb
startback-0.9.0 lib/startback/bus/memory/sync.rb
startback-0.8.3 lib/startback/bus/memory/sync.rb
startback-0.8.2 lib/startback/bus/memory/sync.rb
startback-0.8.1 lib/startback/bus/memory/sync.rb
startback-0.8.0 lib/startback/bus/memory/sync.rb
startback-0.7.6 lib/startback/bus/memory/sync.rb
startback-0.7.5 lib/startback/bus/memory/sync.rb
startback-0.7.4 lib/startback/bus/memory/sync.rb
startback-0.7.3 lib/startback/bus/memory/sync.rb
startback-0.7.2 lib/startback/bus/memory/sync.rb
startback-0.7.1 lib/startback/bus/memory/sync.rb
startback-0.7.0 lib/startback/bus/memory/sync.rb
startback-0.6.0 lib/startback/bus/memory/sync.rb