Closed mwise closed 9 years ago
Hrm noticed that Travis CI borked on this. I don't know if that BubbleWrap::Motion.manager spec blowup is related to this change, but I didn't see it locally.
Travis has been REALLY squirrely recently with rubymotion projects. We're seeing lots of failures in ProMotion and then we re-run it and it works, then it randomly doesn't. grrrr.
Off-tangent a little, but I have been hesitant to contribute because my PRs always seem to fail at Travis and I really have not much of an interest in wasting time fighting it.
I completely understand @hboon. It seems that all the other maintainers of the project have gone missing and I haven't been able to give it the TLC that I need to merge all these PRs and release a new version. :cry:
This PR updates
Eventable#off
to remove all listeners for the given event if neither a method or a block is passed. This behavior is useful when the method or block that you've attached withon()
has fallen out of scope, or if you're quite sure you want to stop handling a particular event altogether.In practice, the need for this behavior showed up when I was listening to a set of Eventables from UITableViewCell instances inside a UIPopoverController view. I needed to remove and re-add event listeners when the UITableViewCells were reused or the popover was closed and reopened. The Eventable instances were retained throughout, but the instances that were calling
on()
andoff()
were falling in and out of ruby scope. As such, I couldn't remove the block handlers, since the equality check driving thedelete_if
was failing.I'm not sure if this is a breaking change, since it doesn't seem that
off()
does anything when called this way currently. The specs pass, and I haven't noticed any adverse affects in our app, although there are no doubt many sides to BubbleWrap that we are not using.Anyway, thanks for this great library! Please take a look and let me know if there's anything that needs updating with the PR or if it is a terrible idea for some reason.
Cheers,
Mark