Class LambdaStreamObserver<V>

  • Type Parameters:
    V - the type of elements being observed
    All Implemented Interfaces:
    io.grpc.stub.StreamObserver<V>

    public class LambdaStreamObserver<V>
    extends Object
    implements io.grpc.stub.StreamObserver<V>
    A StreamObserver that uses lambdas to handle the various messages.
    • Method Detail

      • onNext

        public void onNext​(V value)
        Specified by:
        onNext in interface io.grpc.stub.StreamObserver<V>
      • onError

        public void onError​(Throwable error)
        Specified by:
        onError in interface io.grpc.stub.StreamObserver<V>
      • onCompleted

        public void onCompleted()
        Specified by:
        onCompleted in interface io.grpc.stub.StreamObserver<V>
      • create

        public static <T> io.grpc.stub.StreamObserver<T> create​(Consumer<T> onNext)
        Create a StreamObserver that passes values received by its StreamObserver.onNext(Object) method to a Consumer.
        Type Parameters:
        T - the type of value to receive
        Parameters:
        onNext - the Consumer to receive the values
        Returns:
        a StreamObserver
      • create

        public static <T> io.grpc.stub.StreamObserver<T> create​(Consumer<T> onNext,
                                                                Runnable onComplete,
                                                                Consumer<Throwable> onError)
        Create a StreamObserver that uses the specified lambda to handle events.
        Type Parameters:
        T - the type of value to receive
        Parameters:
        onNext - the Consumer to receive the values
        onComplete - the Runnable to execute when the observer completes
        onError - the Consumer to receive any errors
        Returns:
        a StreamObserver