/// <inheritdoc /> /// <summary> /// Called by the View. Handles UiEvent notification /// </summary> public virtual void HandleUiEvent(string key, object data) { Action <object> action; if (UiEventsMap.TryGetValue(key, out action)) { action.Invoke(data); } }
/// <inheritdoc /> /// <summary> /// Handles UI event from UI/ViewModel. Looks for IMediators interested in the key /// </summary> /// <param name="key">Event key</param> /// <param name="body">Optional body</param> /// <returns>False if no one is interested</returns> public virtual bool HandleUiEvent(string key, object body) { IList <IMediator> mediators; if (UiEventsMap.TryGetValue(key, out mediators)) { foreach (var m in mediators) { m.HandleUiEvent(key, body); } } else { return(false); } return(true); }
public virtual void AddUiEventListener(string key, IMediator mediator) { IList <IMediator> mediators; if (UiEventsMap.TryGetValue(key, out mediators)) { if (!mediators.Contains(mediator)) { UiEventsMap[key].Add(mediator); } } else { UiEventsMap.Add(key, new List <IMediator> { mediator }); } }