Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

UDBase.Controllers.EventSystem

konh edited this page Apr 25, 2018 · 2 revisions

EventController

Default event controller

public class UDBase.Controllers.EventSystem.EventController
    : IEvent, ILogContext

Methods

Type Name Summary
void Fire(T arg)
Dictionary<Type, List<Object>> GetHandlers() Gets the handlers for further use in EventWindow
void Subscribe(Object handler, Action<T> callback)
void Unsubscribe(Action<T> action)

IEvent

IEvent is a lightweight event system, based on System.Action. It does not use UnityEvent or native C# event/delegate way. You can use both class and struct as event object. For prevent leak issues you need to unsubscribe from events when you doesn't need them, e.g. in OnDisable/OnDestroy. Unsubscribing is required for custom classes, for MonoBehaviour classes it recommended, because before each event firing watchers checked for destroyed scripts and remove it (but if event is rare it may not happen).

public interface UDBase.Controllers.EventSystem.IEvent

Methods

Type Name Summary
void Fire(T arg)
void Subscribe(Object handler, Action<T> callback)
void Unsubscribe(Action<T> callback)