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