/** * Returns a Nono that completes normally. * @return the new Nono instance */ public static Nono complete() { return onAssembly(NonoComplete.INSTANCE); }
/** * Repeatedly run this Nono at most the given number of times if it fails. * @param times the repeat count * @return the new Nono instance */ public final Nono retry(long times) { return onAssembly(new NonoRetry(this, times)); }
/** * Caches the terminal event of the upstream Nono * and relays/replays it to Subscribers. * @return the new Nono instance * * @since 0.14.1 */ public final Nono cache() { return onAssembly(new NonoCache(this)); }
/** * Run the other Nono when this Nono completes. * @param other the other Nono to continue with. * @return the new Nono instance */ public final Nono andThen(Nono other) { ObjectHelper.requireNonNull(other, "other is null"); return onAssembly(new NonoAndThen(this, other)); }
/** * If this Nono signals an error, subscribe to the fallback Nono * returned by the error handler function. * @param errorHandler the function called with the error and should * return a Nono to resume with. * @return the new Nono instance */ public final Nono onErrorResumeNext(Function<? super Throwable, ? extends Nono> errorHandler) { ObjectHelper.requireNonNull(errorHandler, "errorHandler is null"); return onAssembly(new NonoOnErrorResume(this, errorHandler)); }
/** * Executes the callback exactly if the upstream terminates or * the downstream cancels the sequence. * @param onFinally the action to call * @return the new Nono instance */ public final Nono doFinally(Action onFinally) { ObjectHelper.requireNonNull(onFinally, "action is null"); return onAssembly(new NonoDoFinally(this, onFinally)); }
/** * Returns a Nono that signals the given Throwable to all * subscribers. * @param ex the Throwable to signal, not null * @return the new Nono instance */ public static Nono error(Throwable ex) { ObjectHelper.requireNonNull(ex, "ex is null"); return onAssembly(new NonoError(ex)); }
/** * Blockingly waits indefinitely for the given Future to terminate, * relaying any error the Future signals. * @param future the future to await * @return the new Nono instance */ public static Nono fromFuture(Future<?> future) { ObjectHelper.requireNonNull(future, "future is null"); return onAssembly(new NonoFromFuture(future, 0L, TimeUnit.NANOSECONDS)); }
/** * Returns a Nono that terminates when the first Nono from the * sources sequence terminates. * @param sources the Iterable sequence of sources * @return the new Nono instance */ public static Nono amb(Iterable<? extends Nono> sources) { ObjectHelper.requireNonNull(sources, "sources is null"); return onAssembly(new NonoAmbIterable(sources)); }
/** * Returns a Nono that terminates when the first Nono from the * array terminates. * @param sources the array of sources * @return the new Nono instance */ public static Nono ambArray(Nono... sources) { ObjectHelper.requireNonNull(sources, "sources is null"); return onAssembly(new NonoAmbArray(sources)); }
/** * Signal a TimeoutException if the other Publisher signals an item * or completes before this Nono completes. * @param other the other Publisher instance * @return the new Nono instance */ public final Nono timeout(Publisher<?> other) { ObjectHelper.requireNonNull(other, "other is null"); return onAssembly(new NonoTimeout(this, other, null)); }
/** * Transform the downstream's Subscriber into a Subscriber for the upstream * via a function. * @param lifter the function receiving the downstream Subscriber and returns a Subscriber * for the upstream. * @return the new Nono instance */ public final Nono lift(Function<Subscriber<? super Void>, Subscriber<? super Void>> lifter) { ObjectHelper.requireNonNull(lifter, "lifter is null"); return onAssembly(new NonoLift(this, lifter)); }
/** * Creates a Nono instance that when subscribed to, the given onCreate is * called for each individual subscriber to generate a terminal event * synchronously and synchronously in a cancellation-safe manner. * @param onCreate called for each individual subscriber with the abstraction * of the incoming Subscriber * @return the new Nono instance */ public static Nono create(CompletableOnSubscribe onCreate) { ObjectHelper.requireNonNull(onCreate, "onCreate is null"); return onAssembly(new NonoCreate(onCreate)); }
/** * Runs the Nono sources one after the other. * @param sources the array of sources * @return the new Nono instances */ public static Nono concatArray(Nono... sources) { ObjectHelper.requireNonNull(sources, "sources is null"); return onAssembly(new NonoConcatArray(sources, false)); }
/** * Runs the Nono sources one after the other, delaying errors from them * till all sources have terminated. * @param sources the Iterable sequence of sources * @return the new Nono instances */ public static Nono concatDelayError(Iterable<? extends Nono> sources) { ObjectHelper.requireNonNull(sources, "sources is null"); return onAssembly(new NonoConcatIterable(sources, true)); }
/** * Wrap a Maybe, ignore its success value and terminate if * the source Maybe terminates. * @param source the MaybeSource to wrap into a Nono * @return the new Nono instance */ public static Nono fromMaybe(MaybeSource<?> source) { ObjectHelper.requireNonNull(source, "source is null"); return onAssembly(new NonoFromMaybe(source)); }
/** * Delays the actual subscription to this Nono until the other * Publisher signals an item or completes. * @param other the other Publisher to await a signal from * @return the new Nono instance */ public final Nono delaySubscription(Publisher<?> other) { ObjectHelper.requireNonNull(other, "other is null"); return onAssembly(new NonoDelaySubscription(this, other)); }
/** * Maps the upstream error into another Throwable via a function. * @param mapper the function that receives the upstream Throwable * and should return another Throwable to be emitted to downstream * @return the new Nono instance */ public final Nono mapError(Function<? super Throwable, ? extends Throwable> mapper) { ObjectHelper.requireNonNull(mapper, "mapper is null"); return onAssembly(new NonoMapError(this, mapper)); }
/** * Runs the maximum number of Nono sources at once and terminates when all source * Nono terminate, delaying errors in the process. * @param sources the Iterable sequence of Nono sources * @param maxConcurrency the maximum number of active Nono sources at a given time * @return the new Nono instance */ public static Nono mergeDelayError(Iterable<? extends Nono> sources, int maxConcurrency) { ObjectHelper.requireNonNull(sources, "sources is null"); ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency"); return onAssembly(new NonoMergeIterable(sources, true, maxConcurrency)); }
/** * Switch to the fallback Nono if the other Publisher signals an * item or completes before this Nono completes. * @param other the other Publisher instance * @param fallback the fallback Nono instance * @return the new Nono instance */ public final Nono timeout(Publisher<?> other, Nono fallback) { ObjectHelper.requireNonNull(other, "other is null"); ObjectHelper.requireNonNull(fallback, "fallback is null"); return onAssembly(new NonoTimeout(this, other, fallback)); }