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_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”
34 35 36 37 38 |
# File 'lib/motion/events.rb', line 34 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_now_and_on(object, event, &block) ⇒ Object
16 17 18 |
# File 'lib/motion/events.rb', line 16 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
26 27 28 29 30 |
# File 'lib/motion/events.rb', line 26 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
43 44 45 46 47 |
# File 'lib/motion/events.rb', line 43 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.
12 13 14 |
# File 'lib/motion/events.rb', line 12 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
21 22 23 |
# File 'lib/motion/events.rb', line 21 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
50 51 52 53 54 |
# File 'lib/motion/events.rb', line 50 def rmext_trigger(event, value=nil) if @rmext_events_proxy @rmext_events_proxy.trigger(event, value) end end |