Sha256: 2edbb097e20e49eb69c67de0e250ba877fc982d1b9af13b5417f78a5180e0d5b
Contents?: true
Size: 668 Bytes
Versions: 2
Compression:
Stored size: 668 Bytes
Contents
require 'thread' require 'observed/basic_event_bus' module Observed class EventBus def initialize(args={}) @bus = Observed::BasicEventBus.new @receives = {} @task_factory = args[:task_factory] || fail("The parameter :task_factory is missing in args(#{args}") @mutex = ::Mutex.new end def emit(tag, *params) @task_factory.task { |*params| @bus.emit tag, *params params } end def receive(pattern) task = @task_factory.mutable_task {|data, options| [data, options] } @bus.on_receive(pattern) do |*params| task.now(*params) end task end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
observed-0.2.0 | lib/observed/event_bus.rb |
observed-0.2.0.rc2 | lib/observed/event_bus.rb |