Hi Will,
Congratulations on the baby and thank you for being awake enough to respond! We really appreciate it!
Yes, we are seeing SignalMediationBinder properly handling the ListensTo delegates.
Here was our patch. Let me know if you think there is a cleaner solution, if not I'll issue a PR with this.
Changes to MediationBinder.DestroyMediator:
(1) Call UnityEngine.Object.Destroy on the IMediator after calling OnRemove by casting it as a Component. Always return null since the mediator is dead at this point...
/// Destroy the Mediator on the provided view object based on the mediatorType
protected override IMediator DestroyMediator(IView view, Type mediatorType)
{
var mono = view as MonoBehaviour;
IMediator mediator = mono.GetComponent(mediatorType) as Mediator;
if (mediator != null)
{
mediator.OnRemove();
Object.Destroy((Component) mediator);
}
return null;
}
Changes to SignalMediationBinder.DestroyMediator:
(1) Copy paste everything from MediationBinder.DestroyMediator: up to the IMediator.OnRemove
(2) Handle the delegates
(3) Call UnityEngine.Object.Destroy on the IMediator after calling OnRemove by casting it as a Component. Always return null since the mediator is dead at this point...
/// Manage Delegates, then remove the Mediator from a View
protected override IMediator DestroyMediator(IView view, Type mediatorType)
{
var mono = view as MonoBehaviour;
IMediator mediator = mono.GetComponent(mediatorType) as Mediator;
if (mediator != null)
{
mediator.OnRemove();
HandleDelegates(mediator, mediatorType,false);
Object.Destroy((Component)mediator);
}
return null;
}