strangeioc/strangeioc — pull request #105 by mikecann (2014-06-08 09:34:19+00:00)
Title: Added code to allow for automatic un-listening to signals in mediators

As per this post: https://groups.google.com/forum/#!topic/strangeioc/xXCq-2zm4U4

You can now simply extend "SignalsMediator" then use any "RegisterListener" method to have your signals automatically unlistened when the mediator is destroyed.

To accomplish this I have added a "SignalBinding" class (well 4 of them actually) that maintains a reference between the signal and the listener. That way the binding can be stored in a single list in SignalsMediator (they all implement ISignalBinding) and thus can be iterated over when the mediator is destroyed.

For added sugar I have added a "OnPreRemove" method to IMediator and gets called immediately before OnRemove, this allows SignalsMediator (and any other base classes) to do any cleaning up and not worry that OnRemove may be overridden and not be calling the super OnRemove.

I have included some tests although I havent actually run them from within the source directory as I had issues with how to structure the git clone (see https://groups.google.com/forum/#!topic/strangeioc/pb8reQ208TQ)