Interface Single<V>

  • Type Parameters:
    V - Type of the datum emitted
    All Superinterfaces:
    org.reactivestreams.Publisher<V>

    public interface Single<V>
    extends org.reactivestreams.Publisher<V>
    Single is a reactive-streams compatible promise. It extends Publisher by providing additional reactive methods allowing to act on it. The goal of this interface is to decouple ourself from reactive framework (RxJava/Reactor).
    • Method Detail

      • map

        <O> Single<O> map​(org.forgerock.util.Function<V,​O,​Exception> function)
        Transforms the value emitted by this single.
        Type Parameters:
        O - Type of the datum emitted after transformation
        Parameters:
        function - Function to apply to the result of this single.
        Returns:
        A new Single with the transformed value.
      • flatMap

        <O> Single<O> flatMap​(org.forgerock.util.Function<V,​Single<O>,​Exception> function)
        Transforms asynchronously the value emitted by this single into another.
        Type Parameters:
        O - Type of the datum emitted after transformation
        Parameters:
        function - Function to apply to perform the asynchronous transformation
        Returns:
        A new Single transforming the datum emitted by this Single.
      • onErrorResumeWith

        Single<V> onErrorResumeWith​(org.forgerock.util.Function<Throwable,​Single<V>,​Exception> function)
        When an error occurs in this stream, continue the processing with the new Single provided by the function.
        Parameters:
        function - Generates the single which must will used to resume operation when this Single failed.
        Returns:
        A new Single
      • subscribe

        void subscribe​(Consumer<? super V> resultConsumer,
                       Consumer<Throwable> errorConsumer)
        Subscribe to the single value emitted by this Single.
        Parameters:
        resultConsumer - A Consumer which will be invoked by the value emitted by this single
        errorConsumer - A Consumer which will be invoked with the error emitted by this single