Interface Asyncc.IAsyncCallback<T,E>

Type Parameters:
T - result value type
E - error type (typically Throwable, but can be any reference type)
All Known Subinterfaces:
NeoTimesI.ITimesCallback<T,E>, NeoWaterfallI.IAsyncCallback<T,E>
All Known Implementing Classes:
Asyncc.AsyncCallback, NeoEachI.EachCallback, NeoFilterI.AsyncCallback, NeoFilterMapI.AsyncCallback, NeoGroupByI.AsyncCallback, NeoInjectI.AsyncCallbackSet, NeoMapI.AsyncCallback, NeoRaceIfc.RaceCallback, NeoWaterfallI.AsyncCallback, NeoWhilstI.AsyncCallback
Enclosing class:
Asyncc

public static interface Asyncc.IAsyncCallback<T,E>
Error-first callback (Node.js-style). The combinators' final callback and per-task callback both use this interface.

The conventional parameter name in user code is c, short for continuation. The continuation receives the result of an async step and is responsible for "what happens next" — either the final callback of the combinator, or the next inner step.

Three ways to fire the continuation:

   c.done(null, value);   // legacy / explicit error-first form (still works)
   c.success(value);      // shorthand for done(null, value) — added in v0.2.4
   c.fail(err);           // shorthand for done(err, null)   — added in v0.2.4
 

For the common case where the caller does not want to handle the error inline, use WrapErrFirst.wrap(java.util.function.Consumer) to wrap a value-only consumer into an error-first callback that throws on any non-null error.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final boolean
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    done(E e, T v)
    Fire the continuation with either an error or a value (never both).
    default void
    fail(E e)
    Fire the continuation with an error.
    default void
     
    default void
    Fire the continuation with a successful value.
  • Field Details

  • Method Details

    • done

      void done(E e, T v)
      Fire the continuation with either an error or a value (never both).
      Parameters:
      e - the error, or null for success
      v - the value, or null when e is non-null
    • success

      default void success(T v)
      Fire the continuation with a successful value. Equivalent to done(null, v).

      Added in v0.2.4.

    • fail

      default void fail(E e)
      Fire the continuation with an error. Equivalent to done(e, null).

      Added in v0.2.4.

    • setDone

      default void setDone()