package ninja.ugly.prevail.event.dispatcher; /** * An EventDispatcher is responsible for delivering events generated by EventFactories during operations * on Chunks. * <p> * This interface is intended to be implemented by instances that use, for example, Guava's EventBus or GreenRobot's * EventBus on Android. Such implementations use runtime types to match events to subscribers. As such, * the methods in this class are type-free. */ public interface EventDispatcher { /** * Dispatch an arbitrary event object to the registered subscribers. * * @param event The event to dispatch. */ void dispatchEvent(Object event); /** * Register a subscriber with this EventDispatcher. * * @param subscriber The subscriber to register. */ void register(Object subscriber); /** * Unregister a subscriber from this EventDispatcher. * * @param subscriber The subscriber to unregister. */ void unregister(Object subscriber); /** * An empty implementation of the EventDispatcher. Useful to instantiate as an initial value inside * a Chunk, rather than null. */ public static final class EmptyEventDispatcher implements EventDispatcher { @Override public void dispatchEvent(final Object event) { // Do nothing. } @Override public void register(final Object subscriber) { // Do nothing. } @Override public void unregister(final Object subscriber) { // Do nothing } } }