Package org.refcodes.eventbus
Interface GenericBusObservable<E extends org.refcodes.observer.GenericEvent<?>,O extends org.refcodes.observer.Observer<E>,MATCH extends org.refcodes.observer.EventMatcher<E>,H>
-
- Type Parameters:
E- the element typeO- the generic typeMATCH- the generic typeH- the generic type
- All Superinterfaces:
org.refcodes.component.HandleLookup<H,O>
- All Known Subinterfaces:
EventBus,GenericEventBus<E,O,MATCH,META,H>
- All Known Implementing Classes:
AbstractEventBus,EventBusImpl
public interface GenericBusObservable<E extends org.refcodes.observer.GenericEvent<?>,O extends org.refcodes.observer.Observer<E>,MATCH extends org.refcodes.observer.EventMatcher<E>,H> extends org.refcodes.component.HandleLookup<H,O>TheObservablepart of theGenericEventBusprovides means to registerObserverinstances.In case your
GenericBusObservablenotifies upon events of typeActionMetaDataEvent, you may use theActionMetaDataEventImpland an action for distinguishing your various types of notification:TIPP: In order to distinguish
ActionMetaDataEventImplinstances from each other, create an actions enumeration, enumerating the various event actions you support. Pass the actual action you intend to notify upon to the according constructor, as anObserveryou may use the declarative methodEventMatcherSugar.actionEqualWith(Object)to test whether your action was notified (or a simple switch case statement).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <EVT extends E>
Hsubscribe(java.lang.Class<EVT> aEventType, MATCH aEventMatcher, org.refcodes.observer.Observer<EVT> aObserver)Subscribes a listener to the event bus.<EVT extends E>
Hsubscribe(java.lang.Class<EVT> aEventType, org.refcodes.observer.Observer<EVT> aObserver)Subscribes a listener to the event bus.Hsubscribe(MATCH aEventMatcher, O aObserver)Subscribes a listener to the event bus.voidunsubscribeAll(O aObserver)Unsubscribes all registrations to a specific listener, even if that listener is involved in several subscriptions.
-
-
-
Method Detail
-
subscribe
H subscribe(MATCH aEventMatcher, O aObserver)
Subscribes a listener to the event bus. In case the handle is being ignored, use the "unsubscribeAll" method where all subscriptions for a listener are removed.- Parameters:
aEventMatcher- TheEventMatcherto guard theObserver.aObserver- TheObserverto subscribe.- Returns:
- A handle to unsubscribe this combination.
-
subscribe
<EVT extends E> H subscribe(java.lang.Class<EVT> aEventType, org.refcodes.observer.Observer<EVT> aObserver)
Subscribes a listener to the event bus. In case the handle is being ignored, use the "unsubscribeAll" method where all subscriptions for a listener are removed.- Type Parameters:
EVT- The type of the event to subscribe for.- Parameters:
aEventType- The type of event to observe.aObserver- TheObserverto subscribe.- Returns:
- A handle to unsubscribe this combination.
-
subscribe
<EVT extends E> H subscribe(java.lang.Class<EVT> aEventType, MATCH aEventMatcher, org.refcodes.observer.Observer<EVT> aObserver)
Subscribes a listener to the event bus. In case the handle is being ignored, use the "unsubscribeAll" method where all subscriptions for a listener are removed.- Type Parameters:
EVT- The type of the event to subscribe for.- Parameters:
aEventType- The type of event to observe.aEventMatcher- TheEventMatcherto guard theObserver.aObserver- TheObserverto subscribe.- Returns:
- A handle to unsubscribe this combination.
-
unsubscribeAll
void unsubscribeAll(O aObserver)
Unsubscribes all registrations to a specific listener, even if that listener is involved in several subscriptions.- Parameters:
aObserver- the observer
-
-