Anything that can be
observed, that is have an
observer
added and removed. Each
Observable has one canonical observer
type, which can be added by the
addObserver(Object)
method and
removed by the
removeObserver(Object)
method, or added by the
observe(Object)
method and removed by the returned
Subscription.
In specific subtypes, methods for adding/removing canonical observers may
have aliases that are more descriptive for the specific type, for example,
in
EventStream
,
observe(Object) is aliased as
EventStream.subscribe(java.util.function.Consumer), or in
Val
,
addObserver(Object) is aliased as
Val.addInvalidationObserver(java.util.function.Consumer).
In addition to the canonical observer, subtypes may support adding other
observer types. These other observers will be wrapped to "look like" a
canonical observer. For example, the canonical observer for
Val<T>
is an
invalidation observer, which is of type
Consumer<? super T>
, which accepts the invalidated value.
In addition to this canonical observer,
Val also supports
InvalidationListener
s and
ChangeListener
s.