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.

@FunctionalInterface public interface Subscriber<T>
Interface for subscribing to (possibly asynchronous) events that are published by a Subscribable.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Invoked when the Subscribable is marked as completed, after which this Subscriber will no longer receive events.
    default void
    Invoked by the Subscribable when an error has occurred while publishing an event.
    void
    onEvent(T event)
    Invoked by the Subscribable when an event has been received.
  • Method Details

    • onEvent

      void onEvent(T event)
      Invoked by the Subscribable when an event has been received.
    • onError

      default void onError(Exception error)
      Invoked by the Subscribable 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 the Subscribable is marked as completed, after which this Subscriber will no longer receive events. This is an optional method, the default implementation does nothing.