Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Robotlegs/Bender/Extensions/Mediation/API/IView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace Robotlegs.Bender.Extensions.Mediation.API
public interface IView
{
event Action<IView> RemoveView;

void Ready();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@ public void RemoveMapping(IMediatorMapping mapping)
public void HandleView(object view, Type type)
{
List<IMediatorMapping> interestedMappings = GetInterestedMappingsFor(view, type);
if (interestedMappings != null)
List<object> mediators = new List<object>();

if (interestedMappings != null)
{
_factory.CreateMediators (view, type, interestedMappings);
mediators = _factory.CreateMediators (view, type, interestedMappings);
}

if(mediators != null && mediators.Count > 0)
{
if(view is IView)
(view as IView).Ready();
}
}

/*============================================================================*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,31 @@

namespace Robotlegs.Bender.Platforms.Unity.Extensions.Mediation.Impl
{
public class View : MonoBehaviour, IView
{
public event Action<IView> RemoveView
{
add
{
_removeView += value;
}
remove
{
_removeView -= value;
}
}

private Action<IView> _removeView;

protected virtual void Start ()
{
ViewNotifier.RegisterView(this);
}
public class View : MonoBehaviour, IView
{
public event Action<IView> RemoveView
{
add
{
_removeView += value;
}
remove
{
_removeView -= value;
}
}

private Action<IView> _removeView;

protected virtual void Start()
{
ViewNotifier.RegisterView(this);
}

public virtual void Ready()
{

}

protected virtual void OnDestroy ()
{
Expand Down