/// <summary> /// Subscribe handler to specific TEvent type by interface /// </summary> /// <typeparam name="TEvent"></typeparam> /// <param name="handler"></param> public virtual void Subscribe <TEvent>(ICanHandle <TEvent> handler) { Subscribe <TEvent>(handler.Handle); }
/// <summary> /// Subscribe handler to specific TEvent type by interface /// </summary> /// <typeparam name="TEvent"></typeparam> /// <param name="handler"></param> public static void Subscribe <TEvent>(ICanHandle <TEvent> handler) { Default.Subscribe <TEvent>(handler.Handle); }
/// <summary> /// Subscribe to event with special behavior when handler failed. If it fails with TException - onFail is called /// </summary> public static Delegate <TEvent> AddOnFail <TEvent, TException>(this ICanHandle <TEvent> handler, FailDelegate <TEvent> onFailHandler, OnException.DelegateInterface onException = null) where TException : Exception { return(AddOnFail <TEvent, TException>(handler.Handle, onFailHandler, onException)); }
public static Delegate <TEvent> Retry <TEvent, TException>(this ICanHandle <TEvent> handler, int times) where TException : Exception { return(Retry <TEvent, TException>(handler.Handle, times, NoDelayForRetry)); }
/// <summary> /// Wraps handler for Asynchronous execution /// </summary> /// <typeparam name="TEvent"></typeparam> /// <param name="handler"></param> /// <returns></returns> public static Delegate <TEvent> Async <TEvent>(this ICanHandle <TEvent> handler, EventBusService eventBusService = null) { Delegate <TEvent> handlerAsDelegate = handler.Handle; return(Async <TEvent>(handlerAsDelegate, eventBusService)); }
/// <summary> /// Subscribe to event with special behavior when handler failed. If it fails with TException - onFail is called /// </summary> public static Delegate <QueuedEvent <TEvent> > WhenRetryQueueFailed <TEvent>(this ICanHandle <QueuedEvent <TEvent> > handler, FailDelegate <QueuedEvent <TEvent> > onFailHandler) { return(WhenRetryQueueFailed <TEvent>(handler.Handle, onFailHandler)); }
/// <summary> /// Subscribe to event with special behavior when handler failed. If it fails with TException - onFail is called /// </summary> public static Delegate <QueuedEvent <TEvent> > WhenRetryQueueFailed <TEvent>(this Delegate <QueuedEvent <TEvent> > handler, ICanHandle <QueuedEvent <TEvent> > onFailHandler) { return(WhenRetryQueueFailed <TEvent>(handler, (a, e) => onFailHandler.Handle(a))); }
/// <summary> /// Wraps handler to handle events which has been queued /// </summary> /// <typeparam name="TEvent">Handler to use</typeparam> /// <param name="handler">Handler to use</param> /// <returns></returns> public static Delegate <QueuedEvent <TEvent> > WhenQueued <TEvent>(this ICanHandle <TEvent> handler) { Delegate <TEvent> handlerAsDelegate = handler.Handle; return(WhenQueued(handlerAsDelegate)); }
public static Delegate <TEvent> Retry <TEvent, TException>(this ICanHandle <TEvent> handler, int times, TimeSpan interval) where TException : Exception { return(Retry <TEvent, TException>(handler.Handle, times, interval)); }