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