E
- the element typeO
- the generic typeEM
- the generic typeH
- the generic typepublic interface BusObservable<E extends org.refcodes.observer.GenericEvent<?>,O extends org.refcodes.observer.Observer<E>,EM extends org.refcodes.observer.EventMatcher<E>,H>
extends org.refcodes.component.HandleLookup<H,O>
Observable
part of the GenericEventBus
provides means to
register Observer
instances.
In case your BusObservable
notifies upon events of type
ActionMetaDataEvent
, you may use the
ActionMetaDataEventImpl
and an action for distinguishing your various
types of notification:
TIPP: In order to distinguish ActionMetaDataEventImpl
instances 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 an Observer
you may use the declarative
method EventMatcherSugar.actionEqualWith(Object)
to test whether your
action was notified (or a simple switch case statement).
Modifier and Type | Method and Description |
---|---|
<EVT extends E> |
subscribe(Class<EVT> aEventType,
EM aEventMatcher,
org.refcodes.observer.Observer<EVT> aObserver)
Subscribes a listener to the event bus.
|
H |
subscribe(EM aEventMatcher,
O aObserver)
Subscribes a listener to the event bus.
|
void |
unsubscribeAll(O aObserver)
Unsubscribes all registrations to a specific listener, even if that
listener is involved in several subscriptions.
|
H subscribe(EM aEventMatcher, O aObserver)
aEventMatcher
- The EventMatcher
to guard the
Observer
.aObserver
- The Observer
to subscribe.<EVT extends E> H subscribe(Class<EVT> aEventType, EM aEventMatcher, org.refcodes.observer.Observer<EVT> aObserver)
aEventMatcher
- The EventMatcher
to guard the
Observer
.aObserver
- The Observer
to subscribe.void unsubscribeAll(O aObserver)
aObserver
- the observerCopyright © 2018. All rights reserved.