Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
This PR adds the ability to observe multiple keypaths with the same call/block:
observe @obj, [:name, :age, :location] do
update_description
end
This will call that block if either one of the three keypaths change.
Right now this is implemented using a trivial loop over the original #observe call so the block is only passed old_value and new_value, but maybe we should change the structure so that it passes the keypath that changed into the block as well, so we could do this:
observe @obj, [:name, :age, :location] do |old_value, new_value, key_path|
puts "#{key_path} changed from #{old_value} to #{new_value}"
end
This PR adds the ability to observe multiple keypaths with the same call/block:
This will call that block if either one of the three keypaths change.
Right now this is implemented using a trivial loop over the original #observe call so the block is only passed
old_value
andnew_value
, but maybe we should change the structure so that it passes the keypath that changed into the block as well, so we could do this: