Module: Eventable
- Included in:
- Dominate::Widget::Event
- Defined in:
- lib/dominate/widget/event.rb
Instance Method Summary collapse
-
#fire_event(event, *return_value, &block) ⇒ Object
When the event happens the class where it happens runs this.
Instance Method Details
#fire_event(event, *return_value, &block) ⇒ Object
When the event happens the class where it happens runs this
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dominate/widget/event.rb', line 21 def fire_event(event, *return_value, &block) check_mutex threads = [] @eventable_mutex.synchronize { return false unless @callbacks && @callbacks[event] && !@callbacks[event].empty? @callbacks[event].each do |listener_id, callbacks| begin listener = ObjectSpace._id2ref(listener_id) callbacks.each do |callback| threads << Thread.new do ThreadUtility.with_connection do listener.send callback, *return_value, &block end end end rescue RangeError => re # Don't bubble up a missing recycled object, I don't care if it's not there, I just won't call it raise re unless re..match(/is recycled object/) end end } threads.map(&:join) true end |