namespace Easy.MessageHub
{
using System;
///
/// An implementation of the Event Aggregator pattern.
///
public interface IMessageHub : IDisposable
{
///
/// Registers a callback which is invoked on every message published by the .
/// Invoking this method with a new overwrites the previous one.
///
///
/// The callback to invoke on every message
/// The callback receives the type of the message and the message as arguments
///
void RegisterGlobalHandler(Action onMessage);
///
/// Invoked if an error occurs when publishing a message to a subscriber.
/// Invoking this method with a new overwrites the previous one.
///
void RegisterGlobalErrorHandler(Action onError);
///
/// Publishes the on the .
///
/// The message to published
void Publish(T message);
///
/// Subscribes a callback against the for a specific type of message.
///
/// The type of message to subscribe to
/// The callback to be invoked once the message is published on the
/// The token representing the subscription
Guid Subscribe(Action action);
///
/// Subscribes a callback against the for a specific type of message.
///
/// The type of message to subscribe to
/// The callback to be invoked once the message is published on the
/// The specifying the rate at which subscription is throttled
/// The token representing the subscription
Guid Subscribe(Action action, TimeSpan throttleBy);
///
/// Unsubscribes a subscription from the .
///
/// The token representing the subscription
void Unsubscribe(Guid token);
///
/// Checks if a specific subscription is active on the .
///
/// The token representing the subscription
/// True if the subscription is active otherwise False
bool IsSubscribed(Guid token);
///
/// Clears all the subscriptions from the .
/// The global handler and the global error handler are not affected
///
void ClearSubscriptions();
}
}