lib/ably/modules/event_emitter.rb in ably-0.6.2 vs lib/ably/modules/event_emitter.rb in ably-0.7.0

- old
+ new

@@ -60,10 +60,16 @@ end end # Trigger an event with event_name that will in turn call all matching callbacks setup with `on` def trigger(event_name, *args) - callbacks[callbacks_event_coerced(event_name)].delete_if { |proc_hash| proc_hash[:trigger_proc].call(*args) } + callbacks[callbacks_event_coerced(event_name)]. + clone. + select do |proc_hash| + proc_hash[:trigger_proc].call(*args) + end.each do |callback| + callbacks[callbacks_event_coerced(event_name)].delete callback + end end # Remove all callbacks for event_name. # # If a block is provided, only callbacks matching that block signature will be removed.