lib/eventsimple/event_dispatcher.rb in eventsimple-1.4.2 vs lib/eventsimple/event_dispatcher.rb in eventsimple-1.4.3
- old
+ new
@@ -53,10 +53,11 @@
@rules[event].add_async async
end
end
# Return a ReactorSet containing all Reactors matching an Event
+ # Reactors will be in the order in which they were registered
def for(event)
reactors = ReactorSet.new
@rules.each do |event_class, rule|
# Match event by class including ancestors. e.g. All events match a role for BaseEvent.
@@ -75,19 +76,19 @@
# * return a set of matching reactors with Rules#for
class ReactorSet
attr_reader :sync, :async
def initialize
- @sync = Set.new
- @async = Set.new
+ @sync = []
+ @async = []
end
def add_sync(reactors)
- @sync += reactors
+ @sync |= reactors
end
def add_async(reactors)
- @async += reactors
+ @async |= reactors
end
end
end
end