Package nl.colorize.util
Interface Subscriber<T>
- Type Parameters:
T
- The type of event that can be subscribed to.
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Interface for subscribing to (possibly asynchronous) events that are
published by a
Subscribable
.
This class is part of a portable framework for
publish/subscribe
communication. This framework can be used across different platforms,
including platforms where java.util.concurrent
is not available,
such as TeaVM.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Invoked when theSubscribable
is marked as completed, after which thisSubscriber
will no longer receive events.default void
Invoked by theSubscribable
when an error has occurred while publishing an event.void
Invoked by theSubscribable
when an event has been received.
-
Method Details
-
onEvent
Invoked by theSubscribable
when an event has been received. -
onError
Invoked by theSubscribable
when an error has occurred while publishing an event. This is an optional method, the default implementation will log the error. -
onComplete
default void onComplete()Invoked when theSubscribable
is marked as completed, after which thisSubscriber
will no longer receive events. This is an optional method, the default implementation does nothing.
-