module Lux::EventBus
EventBus.on
('test') { |arg| puts 'jedan: %s' % arg } EventBus.on
('test') { |arg| puts 'dva: %s' % arg } EventBus.on
('test') { |arg| raise 'abc' } EventBus.call
'test', 'xxx'
Constants
- EVENTS
Public Instance Methods
call(name, opts=nil)
click to toggle source
# File lib/lux/event_bus/event_bus.rb, line 18 def call name, opts=nil for func in EVENTS[name].values begin func.call opts rescue => error Lux.config.on_event_bus_error.call error, name end end end
on(name, key=nil, &proc)
click to toggle source
# File lib/lux/event_bus/event_bus.rb, line 11 def on name, key=nil, &proc key ||= caller[0].split(':in ').first.gsub(/[^\w]/,'') EVENTS[name] ||= {} EVENTS[name][key] ||= proc end