lib/glimmer/data_binding/observable_array.rb in glimmer-1.0.7 vs lib/glimmer/data_binding/observable_array.rb in glimmer-1.0.8
- old
+ new
@@ -32,11 +32,11 @@
def add_observer(observer, *element_properties)
element_properties = element_properties.flatten.compact.uniq
return observer if has_observer?(observer) && has_observer_element_properties?(observer, element_properties)
property_observer_list << observer
- observer_element_properties[observer] = element_properties_for(observer) + Set.new(element_properties)
+ observer_element_properties[observer] = element_properties_for(observer) + Concurrent::Set.new(element_properties)
each { |element| add_element_observer(element, observer) }
observer
end
def add_element_observers(element)
@@ -53,11 +53,11 @@
def remove_observer(observer, *element_properties)
element_properties = element_properties.flatten.compact.uniq
if !element_properties.empty?
old_element_properties = element_properties_for(observer)
- observer_element_properties[observer] = element_properties_for(observer) - Set.new(element_properties)
+ observer_element_properties[observer] = element_properties_for(observer) - Concurrent::Set.new(element_properties)
each { |element| element_properties.each { |property| observer.unobserve(element, property) } }
end
if element_properties_for(observer).empty?
property_observer_list.delete(observer)
observer_element_properties.delete(observer)
@@ -85,18 +85,18 @@
def has_observer_element_properties?(observer, element_properties)
element_properties_for(observer).to_a.include_all?(element_properties)
end
def property_observer_list
- @property_observer_list ||= Set.new
+ @property_observer_list ||= Concurrent::Set.new
end
def observer_element_properties
- @observer_element_properties ||= {}
+ @observer_element_properties ||= Concurrent::Hash.new
end
def element_properties_for(observer)
- observer_element_properties[observer] ||= Set.new
+ observer_element_properties[observer] ||= Concurrent::Set.new
end
def notify_observers
property_observer_list.to_a.each(&:call)
end