Module: RMExtensions::ObjectExtensions::Events
- Defined in:
- lib/motion/events.rb
Instance Method Summary collapse
-
#rmext_cleanup ⇒ Object
remove all event callbacks on this object, remove all event callbacks from other objects in this object’s “self”.
- #rmext_events_proxy ⇒ Object
- #rmext_events_proxy? ⇒ Boolean
- #rmext_now_and_on(object, event, &block) ⇒ Object
-
#rmext_off(object, event, &block) ⇒ Object
remove a specific callback for an event on object.
-
#rmext_off_all ⇒ Object
remove all event callbacks on this object.
-
#rmext_on(object, event, &block) ⇒ Object
register a callback when an event is triggered on this object.
-
#rmext_once(object, event, &block) ⇒ Object
register a callback when an event is triggered on this object and remove it after it fires once.
-
#rmext_trigger(event, value = nil) ⇒ Object
trigger an event with value on this object.
Instance Method Details
#rmext_cleanup ⇒ Object
remove all event callbacks on this object, remove all event callbacks from other objects in this object’s “self”
38 39 40 41 42 |
# File 'lib/motion/events.rb', line 38 def rmext_cleanup if @rmext_events_proxy @rmext_events_proxy.cleanup end end |
#rmext_events_proxy ⇒ Object
7 8 9 |
# File 'lib/motion/events.rb', line 7 def rmext_events_proxy @rmext_events_proxy ||= EventsProxy.new(self) end |
#rmext_events_proxy? ⇒ Boolean
11 12 13 |
# File 'lib/motion/events.rb', line 11 def rmext_events_proxy? !@rmext_events_proxy.nil? end |
#rmext_now_and_on(object, event, &block) ⇒ Object
20 21 22 |
# File 'lib/motion/events.rb', line 20 def rmext_now_and_on(object, event, &block) object.rmext_events_proxy.now_and_on(event, inContext:self, withBlock:block) end |
#rmext_off(object, event, &block) ⇒ Object
remove a specific callback for an event on object
30 31 32 33 34 |
# File 'lib/motion/events.rb', line 30 def rmext_off(object, event, &block) if object.rmext_events_proxy? object.rmext_events_proxy.off(event, inContext:self, withBlock:block) end end |
#rmext_off_all ⇒ Object
remove all event callbacks on this object
47 48 49 50 51 |
# File 'lib/motion/events.rb', line 47 def rmext_off_all if @rmext_events_proxy @rmext_events_proxy.off_all end end |
#rmext_on(object, event, &block) ⇒ Object
register a callback when an event is triggered on this object.
16 17 18 |
# File 'lib/motion/events.rb', line 16 def rmext_on(object, event, &block) object.rmext_events_proxy.on(event, limit:-1, inContext:self, withBlock:block) end |
#rmext_once(object, event, &block) ⇒ Object
register a callback when an event is triggered on this object and remove it after it fires once
25 26 27 |
# File 'lib/motion/events.rb', line 25 def rmext_once(object, event, &block) object.rmext_events_proxy.on(event, limit:1, inContext:self, withBlock:block) end |
#rmext_trigger(event, value = nil) ⇒ Object
trigger an event with value on this object
54 55 56 57 58 |
# File 'lib/motion/events.rb', line 54 def rmext_trigger(event, value=nil) if @rmext_events_proxy @rmext_events_proxy.trigger(event, value) end end |