Interface Callbacks


public interface Callbacks
A set of utilities for creating callbacks and promises using lambdas.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
     
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static <S, F> void
    failLog(HasEventHandling failHandler, Consumer<S> from, F failure)
     
    static <S> elemental2.promise.Promise<S>
    grpcUnaryPromise(Consumer<io.grpc.stub.StreamObserver<S>> t)
    Returns a promise that resolves when the first payload arrives from a unary request.
    static <S> elemental2.promise.Promise<Callbacks.Response<S>>
    grpcUnaryPromiseWrapped(Consumer<io.grpc.stub.StreamObserver<S>> t)
    Propagates the message and the context into a Promise, as a promise's microtask will result in losing the context.
    static <T> io.grpc.stub.StreamObserver<T>
     
    static <S> elemental2.promise.Promise.PromiseExecutorCallbackFn.RejectCallbackFn
    notNull(HasEventHandling failHandler, Consumer<S> realCallback, elemental2.promise.Promise.PromiseExecutorCallbackFn.RejectCallbackFn reject)
     
    static <S, F> Callback<S,F>
    of(BiConsumer<S,F> from)
    Transform a bi-consumer into a callback.
    static <S, T> elemental2.promise.Promise<S>
    promise(HasEventHandling failHandler, Consumer<Callback<S,T>> t)
     
  • Method Details

    • ignore

      static <T> io.grpc.stub.StreamObserver<T> ignore()
    • promise

      static <S, T> elemental2.promise.Promise<S> promise(@Nullable HasEventHandling failHandler, Consumer<Callback<S,T>> t)
    • notNull

      static <S> elemental2.promise.Promise.PromiseExecutorCallbackFn.RejectCallbackFn notNull(@Nullable HasEventHandling failHandler, Consumer<S> realCallback, elemental2.promise.Promise.PromiseExecutorCallbackFn.RejectCallbackFn reject)
    • failLog

      static <S, F> void failLog(HasEventHandling failHandler, Consumer<S> from, F failure)
    • of

      static <S, F> Callback<S,F> of(BiConsumer<S,F> from)
      Transform a bi-consumer into a callback. It is the caller's responsibility to fire "requestfailed" events as appropriate.
    • grpcUnaryPromiseWrapped

      static <S> elemental2.promise.Promise<Callbacks.Response<S>> grpcUnaryPromiseWrapped(Consumer<io.grpc.stub.StreamObserver<S>> t)
      Propagates the message and the context into a Promise, as a promise's microtask will result in losing the context. Does not resolve until the unary stream is closed, in order to read the trailers, in contrast with grpcUnaryPromise(Consumer).
    • grpcUnaryPromise

      static <S> elemental2.promise.Promise<S> grpcUnaryPromise(Consumer<io.grpc.stub.StreamObserver<S>> t)
      Returns a promise that resolves when the first payload arrives from a unary request. Because promises resolve on a microtask, the later called promise will not necessarily share the same Context as the call, use grpcUnaryPromiseWrapped(Consumer) for that.