Skip to content

Instantly share code, notes, and snippets.

@sxross
Created October 1, 2014 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sxross/7cfa64b330beacad1409 to your computer and use it in GitHub Desktop.
Save sxross/7cfa64b330beacad1409 to your computer and use it in GitHub Desktop.
MotionModel Watchable
module MotionModel
module Watchable
def self.included(base)
# uncomment if private class methods
# base.extend(PrivateClassMethods)
base.extend(PublicClassMethods)
# base.instance_eval do
# Any instance specific code
# end
end
module PublicClassMethods
def watch(&block)
observer = BW::App.notification_center.observe 'MotionModelDataDidChangeNotification' do |notification|
if notification.object.is_a?(self.ancestors[0])
block.call notification
end
end
observer
end
def stop_watching(observer)
App.notification_center.unobserve observer
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment