lib/motion/events.rb in rm-extensions-0.4.2 vs lib/motion/events.rb in rm-extensions-0.4.3
- old
+ new
@@ -6,10 +6,14 @@
def rmext_events_proxy
@rmext_events_proxy ||= EventsProxy.new(self)
end
+ def rmext_events_proxy?
+ !@rmext_events_proxy.nil?
+ end
+
# register a callback when an event is triggered on this object.
def rmext_on(object, event, &block)
object.rmext_events_proxy.on(event, limit:-1, inContext:self, withBlock:block)
end
@@ -150,10 +154,12 @@
while object = @listenings.anyObject
if ::RMExtensions.debug?
p "CONTEXT:", @weak_object.rmext_object_desc, "UNLISTENING TO:", object.rmext_object_desc
end
@listenings.removeObject(object)
- object.rmext_events_proxy.off_context(@weak_object)
+ if object.rmext_events_proxy?
+ object.rmext_events_proxy.off_context(@weak_object)
+ end
end
end
def trigger(event, value)
rmext_inline_or_on_main_q do