Package org.ores.async
Interface Asyncc.IAsyncCallback<T,E>
- Type Parameters:
T- result value typeE- error type (typicallyThrowable, 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 -
Method Summary
-
Field Details
-
isDone
static final boolean isDone- See Also:
-
-
Method Details
-
done
Fire the continuation with either an error or a value (never both).- Parameters:
e- the error, ornullfor successv- the value, ornullwheneis non-null
-
success
Fire the continuation with a successful value. Equivalent todone(null, v).Added in v0.2.4.
-
fail
Fire the continuation with an error. Equivalent todone(e, null).Added in v0.2.4.
-
setDone
default void setDone()
-