Package hu.akarnokd.rxjava3.basetypes
Class Nono
- java.lang.Object
-
- hu.akarnokd.rxjava3.basetypes.Nono
-
- All Implemented Interfaces:
Publisher<java.lang.Void>
- Direct Known Subclasses:
NonoProcessor
public abstract class Nono extends java.lang.Object implements Publisher<java.lang.Void>
Represents the base reactive class with fluent API for Publisher-based, no-item just onError or onComplete source.Since this type never emits any value, the implementations ignore the downstream request and emit the terminal events even if there was no request (which is allowed by the Reactive-Streams specification).
Since there is no bottom type in Java (that is T is a subtype of all other types), Nono implements the Publisher interface via the Void type parameter.
- Since:
- 0.11.0
-
-
Constructor Summary
Constructors Constructor Description Nono()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Nonoamb(java.lang.Iterable<? extends Nono> sources)Returns a Nono that terminates when the first Nono from the sources sequence terminates.static NonoambArray(Nono... sources)Returns a Nono that terminates when the first Nono from the array terminates.NonoandThen(Nono other)Run the other Nono when this Nono completes.<T> Flowable<T>andThen(Publisher<? extends T> other)When this Nono completes, it is continued by the events of the other Publisher.java.lang.ThrowableblockingAwait()Blockingly await indefinitely the termination of this Nono and return the Throwable if this Nono terminated with an error, null otherwise.java.lang.ThrowableblockingAwait(long timeout, java.util.concurrent.TimeUnit unit)Blockingly await for the given timeout the termination of this Nono and return the Throwable if this Nono terminated with an error, null otherwise.voidblockingSubscribe()Block until this Nono terminates and ignore the actual events.voidblockingSubscribe(Action onComplete)Block until this Nono completes and call the Action on the thread where the blocking happens.voidblockingSubscribe(Action onComplete, Consumer<? super java.lang.Throwable> onError)Block until this Nono terminates and call the Action or Consumer depending on the terminal event on the thread where the blocking happens.static intbufferSize()Returns the default buffer or prefetch size.Nonocache()Caches the terminal event of the upstream Nono and relays/replays it to Subscribers.static Nonocomplete()Returns a Nono that completes normally.Nonocompose(Function<? super Nono,? extends Nono> composer)Compose operators fluently via a function callback that returns a Nono for this Nono.static Nonoconcat(java.lang.Iterable<? extends Nono> sources)Runs the Nono sources one after the other.static Nonoconcat(Publisher<? extends Nono> sources)Runs the Nono sources emitted by the Publisher one after the other.static Nonoconcat(Publisher<? extends Nono> sources, int prefetch)Runs the Nono sources emitted by the Publisher one after the other, prefetching the given number of Nono sources.static NonoconcatArray(Nono... sources)Runs the Nono sources one after the other.static NonoconcatArrayDelayError(Nono... sources)Runs the Nono sources one after the other, delaying errors from them till all sources have terminated.static NonoconcatDelayError(java.lang.Iterable<? extends Nono> sources)Runs the Nono sources one after the other, delaying errors from them till all sources have terminated.static NonoconcatDelayError(Publisher<? extends Nono> sources)Runs the Nono sources emitted by the Publisher, one after the other, delaying errors from them till all sources have terminated.static NonoconcatDelayError(Publisher<? extends Nono> sources, int prefetch, boolean tillTheEnd)Runs the Nono sources emitted by the Publisher, one after the other, delaying errors from them till all sources have terminated and prefetching Nonos from the upstream.static Nonocreate(CompletableOnSubscribe onCreate)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.static Nonodefer(Supplier<? extends Nono> supplier)Defers the creation of the actual Nono instance until a subscriber subscribes.Nonodelay(long delay, java.util.concurrent.TimeUnit unit)Delay the emission of the terminal events of this Nono by the given time amount.Nonodelay(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)Delay the emission of the terminal events of this Nono by the given time amount.NonodelaySubscription(long delay, java.util.concurrent.TimeUnit unit)Delays the actual subscription to this Nono until the given time passes.NonodelaySubscription(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)Delays the actual subscription to this Nono until the given time passes.NonodelaySubscription(Publisher<?> other)Delays the actual subscription to this Nono until the other Publisher signals an item or completes.NonodoAfterTerminate(Action onAfterTerminate)Executes the callback after this Nono terminates and the downstream is notified.NonodoFinally(Action onFinally)Executes the callback exactly if the upstream terminates or the downstream cancels the sequence.NonodoOnCancel(Action onCancel)Executes the callback if the downstream cancels the sequence.NonodoOnComplete(Action onComplete)Executes a callback when the upstream completes normally.NonodoOnError(Consumer<? super java.lang.Throwable> onError)Executes a callback when the upstream signals an error.NonodoOnRequest(LongConsumer onRequest)Executes the callback when the downstream requests from this Nolo.NonodoOnSubscribe(Consumer<? super Subscription> onSubscribe)Executes a callback when the upstream calls onSubscribe.static Nonoerror(Supplier<? extends java.lang.Throwable> errorSupplier)Returns a Nono that signals a Throwable generated by the supplier for each individual subscriber.static Nonoerror(java.lang.Throwable ex)Returns a Nono that signals the given Throwable to all subscribers.<T> Flowable<T>flatMap(Function<? super java.lang.Throwable,? extends Publisher<? extends T>> onErrorMapper, Supplier<? extends Publisher<? extends T>> onCompleteMapper)Maps the upstream completion or error into a Publisher and emit its events as a Flowable.static NonofromAction(Action action)Executes an action when a subscriber subscribes to the returned Nono.static NonofromCompletable(CompletableSource source)Wrap a Completable into a Nono and terminate when the source Completable terminates.static NonofromFuture(java.util.concurrent.Future<?> future)Blockingly waits indefinitely for the given Future to terminate, relaying any error the Future signals.static NonofromFuture(java.util.concurrent.Future<?> future, long timeout, java.util.concurrent.TimeUnit unit)Blockingly waits the given Future for the given timeout to terminate, relaying any error the Future signals.static NonofromMaybe(MaybeSource<?> source)Wrap a Maybe, ignore its success value and terminate if the source Maybe terminates.static NonofromObservable(ObservableSource<?> source)Wrap a general Observable, ignore all of its values and terminate if the source Observable terminates.static NonofromPublisher(Publisher<?> source)Wrap a general Publisher, ignore all of its values and terminate if the source Publisher terminates.static NonofromSingle(SingleSource<?> source)Wrap a Single, ignore its success value and terminate if the source Single terminates.static Function<Nono,Nono>getOnAssemblyHandler()Returns the current onAssembly handler function or null if not set.Nonohide()Hides the identity of this Nono.Nonolift(Function<Subscriber<? super java.lang.Void>,Subscriber<? super java.lang.Void>> lifter)Transform the downstream's Subscriber into a Subscriber for the upstream via a function.NonomapError(Function<? super java.lang.Throwable,? extends java.lang.Throwable> mapper)Maps the upstream error into another Throwable via a function.static Nonomerge(java.lang.Iterable<? extends Nono> sources)Runs all Nono sources at once and completes once all of them complete.static Nonomerge(java.lang.Iterable<? extends Nono> sources, int maxConcurrency)Runs the maximum number of Nono sources at once and completes when all source Nono complete.static Nonomerge(Publisher<? extends Nono> sources)Runs all Nono sources emitted by the Publisher at once and completes once all of them complete.static Nonomerge(Publisher<? extends Nono> sources, int maxConcurrency)Runs the maximum number of Nono sources emitted by the Publisher at once and completes when all source Nono complete.static NonomergeArray(int maxConcurrency, Nono... sources)Runs the maximum number of Nono sources at once and completes when all source Nono complete.static NonomergeArray(Nono... sources)Runs all Nono sources at once and completes once all of them complete.static NonomergeArrayDelayError(int maxConcurrency, Nono... sources)Runs the maximum number of Nono sources at once and terminates when all source Nono terminate, delaying errors in the process.static NonomergeArrayDelayError(Nono... sources)Runs all Nono sources at once and terminates once all of them terminate, delaying errors in the process.static NonomergeDelayError(java.lang.Iterable<? extends Nono> sources)Runs all Nono sources at once and terminates once all of them terminate, delaying errors in the process.static NonomergeDelayError(java.lang.Iterable<? extends Nono> sources, int maxConcurrency)Runs the maximum number of Nono sources at once and terminates when all source Nono terminate, delaying errors in the process.static NonomergeDelayError(Publisher<? extends Nono> sources)Runs all Nono sources emitted by the Publisher at once and terminates once all of them terminate, delaying errors in the process.static NonomergeDelayError(Publisher<? extends Nono> sources, int maxConcurrency)Runs the maximum number of Nono sources emitted by the Publisher at once and terminates when all source Nono terminate, delaying errors in the process.static Nononever()Returns a Nono that never terminates.NonoobserveOn(Scheduler scheduler)Observes the onError and onComplete events on the specified Scheduler.protected static NonoonAssembly(Nono source)Optionally apply a function to the raw source and return a potentially modified Nono instance.NonoonErrorComplete()If this Nono signals an error, signal an onComplete instead.NonoonErrorResumeNext(Function<? super java.lang.Throwable,? extends Nono> errorHandler)If this Nono signals an error, subscribe to the fallback Nono returned by the error handler function.Nonorepeat()Repeatedly run this Nono indefinitely.Nonorepeat(long times)Repeatedly run this Nono at most the given number of times.Nonorepeat(BooleanSupplier stop)Repeat until the given BooleanSupplier returns true.NonorepeatWhen(Function<? super Flowable<java.lang.Object>,? extends Publisher<?>> handler)Repeat when the Publisher returned by the handler function signals a value or terminate accordingly.Nonoretry()Repeatedly run this Nono indefinitely if it fails.Nonoretry(long times)Repeatedly run this Nono at most the given number of times if it fails.Nonoretry(Predicate<? super java.lang.Throwable> predicate)Retry a failed Nono if the predicate return true.NonoretryWhen(Function<? super Flowable<java.lang.Throwable>,? extends Publisher<?>> handler)Retry this Nono when the Publisher returned by the handler function signals a normal item or terminate if the Publisher terminates.static voidsetOnAssemblyHandler(Function<Nono,Nono> handler)Sets the onAssembly handler.Disposablesubscribe()Subscribe to this Nono and ignore the events it produces.Disposablesubscribe(Action onComplete)Subscribe to this Nono and execute the given action if this Nono completes.Disposablesubscribe(Action onComplete, Consumer<? super java.lang.Throwable> onError)Subscribe to this Nono and execute the given action if this Nono completes or call the consumer if this Nono terminates with an error.voidsubscribe(Subscriber<? super java.lang.Void> s)protected abstract voidsubscribeActual(Subscriber<? super java.lang.Void> s)Implement this method to signal the terminal events to the given subscriber.NonosubscribeOn(Scheduler scheduler)Subscribes to the upstream on the specified Scheduler.<T,E extends Subscriber<T>>
EsubscribeWith(E subscriber)Subscribe with the given subscriber and return the same subscriber, allowing chaining methods on it or fluently reusing the instance.NonotakeUntil(Publisher<?> other)Run this Nono and cancel it when the other Publisher signals an item or completes.TestSubscriber<java.lang.Void>test()Create a TestSubscriber, subscribe it to this Nono and return the TestSubscriber itself.TestSubscriber<java.lang.Void>test(boolean cancelled)Create a TestSubscriber, optionally cancel it, subscribe it to this Nono and return the TestSubscriber itself.Nonotimeout(long timeout, java.util.concurrent.TimeUnit unit)Signals a TimeoutException if this Nono doesn't complete within the specified timeout.Nonotimeout(long timeout, java.util.concurrent.TimeUnit unit, Nono fallback)Switches to the fallback Nono if this Nono doesn't complete within the specified timeout.Nonotimeout(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)Signals a TimeoutException if this Nono doesn't complete within the specified timeout.Nonotimeout(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler, Nono fallback)Switches to the fallback Nono if this Nono doesn't complete within the specified timeout.Nonotimeout(Publisher<?> other)Signal a TimeoutException if the other Publisher signals an item or completes before this Nono completes.Nonotimeout(Publisher<?> other, Nono fallback)Switch to the fallback Nono if the other Publisher signals an item or completes before this Nono completes.static Nonotimer(long delay, java.util.concurrent.TimeUnit unit)Completes after the specified amount of time on the computation scheduler.static Nonotimer(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)Completes after the specified amount of time on the specified scheduler.<R> Rto(Function<? super Nono,R> converter)Fluently convert this Nono via a function callback into some type.CompletabletoCompletable()Convert this Nono instance into a Completable.<T> Flowable<T>toFlowable()Convert this Nono instance into a Flowable that only terminates.java.util.concurrent.Future<java.lang.Void>toFuture()Converts this Nono into a Future and signals its single value.<T> Maybe<T>toMaybe()Convert this Nono instance into a Maybe that only terminates.<T> Observable<T>toObservable()Convert this Nono instance into an Observable that only terminates.<T> Perhaps<T>toPerhaps()Convert this Nono instance into a Perhaps that only terminates.NonounsubscribeOn(Scheduler scheduler)If the downstream cancels the sequence, the cancellation towards the upstream will happen on the specified Scheduler.static <R> Nonousing(Supplier<R> resourceSupplier, Function<? super R,? extends Nono> sourceSupplier, Consumer<? super R> disposer)Generate a resource and a Nono based on that resource and then dispose that resource eagerly when the Nono terminates or the downstream cancels the sequence.static <R> Nonousing(Supplier<R> resourceSupplier, Function<? super R,? extends Nono> sourceSupplier, Consumer<? super R> disposer, boolean eager)Generate a resource and a Nono based on that resource and then dispose that resource optionally eagerly when the Nono terminates or the downstream cancels the sequence.
-
-
-
Method Detail
-
bufferSize
public static int bufferSize()
Returns the default buffer or prefetch size.- Returns:
- the buffer or prefetch size
-
onAssembly
protected static Nono onAssembly(Nono source)
Optionally apply a function to the raw source and return a potentially modified Nono instance.- Parameters:
source- the source to apply to- Returns:
- the possibly wrapped Nono instance
-
getOnAssemblyHandler
public static Function<Nono,Nono> getOnAssemblyHandler()
Returns the current onAssembly handler function or null if not set.- Returns:
- the current onAssembly handler function, maybe null
-
setOnAssemblyHandler
public static void setOnAssemblyHandler(Function<Nono,Nono> handler)
Sets the onAssembly handler.- Parameters:
handler- the new onAssembly handler, null clears the handler
-
create
public static Nono create(CompletableOnSubscribe onCreate)
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.- Parameters:
onCreate- called for each individual subscriber with the abstraction of the incoming Subscriber- Returns:
- the new Nono instance
-
complete
public static Nono complete()
Returns a Nono that completes normally.- Returns:
- the new Nono instance
-
never
public static Nono never()
Returns a Nono that never terminates.- Returns:
- the new Nono instance
-
error
public static Nono error(java.lang.Throwable ex)
Returns a Nono that signals the given Throwable to all subscribers.- Parameters:
ex- the Throwable to signal, not null- Returns:
- the new Nono instance
-
error
public static Nono error(Supplier<? extends java.lang.Throwable> errorSupplier)
Returns a Nono that signals a Throwable generated by the supplier for each individual subscriber.- Parameters:
errorSupplier- the Throwable error supplier, not null- Returns:
- the new Nono instance
-
defer
public static Nono defer(Supplier<? extends Nono> supplier)
Defers the creation of the actual Nono instance until a subscriber subscribes.- Parameters:
supplier- the supplier of Nono instances for each individual subscriber.- Returns:
- the new Nono instance
-
fromAction
public static Nono fromAction(Action action)
Executes an action when a subscriber subscribes to the returned Nono.- Parameters:
action- the action to execute, not null- Returns:
- the new nono instance
-
fromFuture
public static Nono fromFuture(java.util.concurrent.Future<?> future)
Blockingly waits indefinitely for the given Future to terminate, relaying any error the Future signals.- Parameters:
future- the future to await- Returns:
- the new Nono instance
-
fromFuture
public static Nono fromFuture(java.util.concurrent.Future<?> future, long timeout, java.util.concurrent.TimeUnit unit)
Blockingly waits the given Future for the given timeout to terminate, relaying any error the Future signals.- Parameters:
future- the future to awaittimeout- the timeout value to wait for terminationunit- the unit for the timeout parameter- Returns:
- the new Nono instance
-
amb
public static Nono amb(java.lang.Iterable<? extends Nono> sources)
Returns a Nono that terminates when the first Nono from the sources sequence terminates.- Parameters:
sources- the Iterable sequence of sources- Returns:
- the new Nono instance
-
ambArray
public static Nono ambArray(Nono... sources)
Returns a Nono that terminates when the first Nono from the array terminates.- Parameters:
sources- the array of sources- Returns:
- the new Nono instance
-
concat
public static Nono concat(java.lang.Iterable<? extends Nono> sources)
Runs the Nono sources one after the other.- Parameters:
sources- the Iterable sequence of sources- Returns:
- the new Nono instances
-
concat
public static Nono concat(Publisher<? extends Nono> sources)
Runs the Nono sources emitted by the Publisher one after the other.- Parameters:
sources- the Publisher of Nono sources- Returns:
- the new Nono instance
-
concat
public static Nono concat(Publisher<? extends Nono> sources, int prefetch)
Runs the Nono sources emitted by the Publisher one after the other, prefetching the given number of Nono sources.- Parameters:
sources- the Publisher of Nono sourcesprefetch- the number of Nono sources to prefetch from upstream- Returns:
- the new Nono instance
-
concatArray
public static Nono concatArray(Nono... sources)
Runs the Nono sources one after the other.- Parameters:
sources- the array of sources- Returns:
- the new Nono instances
-
concatDelayError
public static Nono concatDelayError(java.lang.Iterable<? extends Nono> sources)
Runs the Nono sources one after the other, delaying errors from them till all sources have terminated.- Parameters:
sources- the Iterable sequence of sources- Returns:
- the new Nono instances
-
concatDelayError
public static Nono concatDelayError(Publisher<? extends Nono> sources)
Runs the Nono sources emitted by the Publisher, one after the other, delaying errors from them till all sources have terminated.- Parameters:
sources- the Publisher of source Nonos- Returns:
- the new Nono instances
-
concatDelayError
public static Nono concatDelayError(Publisher<? extends Nono> sources, int prefetch, boolean tillTheEnd)
Runs the Nono sources emitted by the Publisher, one after the other, delaying errors from them till all sources have terminated and prefetching Nonos from the upstream.- Parameters:
sources- the Publisher of source Nonosprefetch- the number of Nonos to prefetch from the upstreamtillTheEnd- if true the errors from the source are also delayed till the end; if false, error(s) are emitted when an inner Nono source terminates- Returns:
- the new Nono instances
-
concatArrayDelayError
public static Nono concatArrayDelayError(Nono... sources)
Runs the Nono sources one after the other, delaying errors from them till all sources have terminated.- Parameters:
sources- the array of sources- Returns:
- the new Nono instances
-
merge
public static Nono merge(java.lang.Iterable<? extends Nono> sources)
Runs all Nono sources at once and completes once all of them complete.- Parameters:
sources- the Iterable sequence of Nono sources- Returns:
- the new Nono instance
-
merge
public static Nono merge(java.lang.Iterable<? extends Nono> sources, int maxConcurrency)
Runs the maximum number of Nono sources at once and completes when all source Nono complete.- Parameters:
sources- the Iterable sequence of Nono sourcesmaxConcurrency- the maximum number of active Nono sources at a given time- Returns:
- the new Nono instance
-
merge
public static Nono merge(Publisher<? extends Nono> sources)
Runs all Nono sources emitted by the Publisher at once and completes once all of them complete.- Parameters:
sources- the Publisher of Nono sources- Returns:
- the new Nono instance
-
merge
public static Nono merge(Publisher<? extends Nono> sources, int maxConcurrency)
Runs the maximum number of Nono sources emitted by the Publisher at once and completes when all source Nono complete.- Parameters:
sources- the Publisher of Nono sourcesmaxConcurrency- the maximum number of active Nono sources at a given time- Returns:
- the new Nono instance
-
mergeArray
public static Nono mergeArray(Nono... sources)
Runs all Nono sources at once and completes once all of them complete.- Parameters:
sources- the array of Nono sources- Returns:
- the new Nono instance
-
mergeArray
public static Nono mergeArray(int maxConcurrency, Nono... sources)
Runs the maximum number of Nono sources at once and completes when all source Nono complete.- Parameters:
sources- the array of Nono sourcesmaxConcurrency- the maximum number of active Nono sources at a given time- Returns:
- the new Nono instance
-
mergeDelayError
public static Nono mergeDelayError(java.lang.Iterable<? extends Nono> sources)
Runs all Nono sources at once and terminates once all of them terminate, delaying errors in the process.- Parameters:
sources- the Iterable sequence of Nono sources- Returns:
- the new Nono instance
-
mergeDelayError
public static Nono mergeDelayError(java.lang.Iterable<? extends Nono> sources, int maxConcurrency)
Runs the maximum number of Nono sources at once and terminates when all source Nono terminate, delaying errors in the process.- Parameters:
sources- the Iterable sequence of Nono sourcesmaxConcurrency- the maximum number of active Nono sources at a given time- Returns:
- the new Nono instance
-
mergeDelayError
public static Nono mergeDelayError(Publisher<? extends Nono> sources)
Runs all Nono sources emitted by the Publisher at once and terminates once all of them terminate, delaying errors in the process.- Parameters:
sources- the Publisher of Nono sources- Returns:
- the new Nono instance
-
mergeDelayError
public static Nono mergeDelayError(Publisher<? extends Nono> sources, int maxConcurrency)
Runs the maximum number of Nono sources emitted by the Publisher at once and terminates when all source Nono terminate, delaying errors in the process.- Parameters:
sources- the Publisher of Nono sourcesmaxConcurrency- the maximum number of active Nono sources at a given time- Returns:
- the new Nono instance
-
mergeArrayDelayError
public static Nono mergeArrayDelayError(Nono... sources)
Runs all Nono sources at once and terminates once all of them terminate, delaying errors in the process.- Parameters:
sources- the array of Nono sources- Returns:
- the new Nono instance
-
mergeArrayDelayError
public static Nono mergeArrayDelayError(int maxConcurrency, Nono... sources)
Runs the maximum number of Nono sources at once and terminates when all source Nono terminate, delaying errors in the process.- Parameters:
sources- the array of Nono sourcesmaxConcurrency- the maximum number of active Nono sources at a given time- Returns:
- the new Nono instance
-
timer
@SchedulerSupport("io.reactivex:computation") public static Nono timer(long delay, java.util.concurrent.TimeUnit unit)
Completes after the specified amount of time on the computation scheduler.- Parameters:
delay- the delay valueunit- the delay time unit- Returns:
- the new Nono instance
-
timer
@SchedulerSupport("custom") public static Nono timer(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Completes after the specified amount of time on the specified scheduler.- Parameters:
delay- the delay valueunit- the delay time unitscheduler- the scheduler to delay the completion signal- Returns:
- the new Nono instance
-
using
public static <R> Nono using(Supplier<R> resourceSupplier, Function<? super R,? extends Nono> sourceSupplier, Consumer<? super R> disposer)
Generate a resource and a Nono based on that resource and then dispose that resource eagerly when the Nono terminates or the downstream cancels the sequence.- Type Parameters:
R- the resource type- Parameters:
resourceSupplier- the callback to get a resource for each subscribersourceSupplier- the function that returns a Nono for the generated resourcedisposer- the consumer of the resource once the upstream terminates or the downstream cancels- Returns:
- the new Nono instance
-
using
public static <R> Nono using(Supplier<R> resourceSupplier, Function<? super R,? extends Nono> sourceSupplier, Consumer<? super R> disposer, boolean eager)
Generate a resource and a Nono based on that resource and then dispose that resource optionally eagerly when the Nono terminates or the downstream cancels the sequence.- Type Parameters:
R- the resource type- Parameters:
resourceSupplier- the callback to get a resource for each subscribersourceSupplier- the function that returns a Nono for the generated resourcedisposer- the consumer of the resource once the upstream terminates or the downstream cancelseager- if true, the resource is disposed before the terminal event is emitted if false, the resource is disposed after the terminal event has been emitted- Returns:
- the new Nono instance
-
fromPublisher
public static Nono fromPublisher(Publisher<?> source)
Wrap a general Publisher, ignore all of its values and terminate if the source Publisher terminates.- Parameters:
source- the Publisher to wrap into a Nono- Returns:
- the Nono instance
-
fromSingle
public static Nono fromSingle(SingleSource<?> source)
Wrap a Single, ignore its success value and terminate if the source Single terminates.- Parameters:
source- the SingleSource to wrap into a Nono- Returns:
- the new Nono instance
-
fromMaybe
public static Nono fromMaybe(MaybeSource<?> source)
Wrap a Maybe, ignore its success value and terminate if the source Maybe terminates.- Parameters:
source- the MaybeSource to wrap into a Nono- Returns:
- the new Nono instance
-
fromCompletable
public static Nono fromCompletable(CompletableSource source)
Wrap a Completable into a Nono and terminate when the source Completable terminates.- Parameters:
source- the MaybeSource to wrap into a Nono- Returns:
- the new Nono instance
-
fromObservable
public static Nono fromObservable(ObservableSource<?> source)
Wrap a general Observable, ignore all of its values and terminate if the source Observable terminates.- Parameters:
source- the ObservableSource to wrap into a Nono- Returns:
- the new Nono instance
-
andThen
public final <T> Flowable<T> andThen(Publisher<? extends T> other)
When this Nono completes, it is continued by the events of the other Publisher.- Type Parameters:
T- the value type of the other Publisher- Parameters:
other- the other Publisher to continue with- Returns:
- the new Flowable instance
-
andThen
public final Nono andThen(Nono other)
Run the other Nono when this Nono completes.- Parameters:
other- the other Nono to continue with.- Returns:
- the new Nono instance
-
delay
@SchedulerSupport("io.reactivex:computation") public final Nono delay(long delay, java.util.concurrent.TimeUnit unit)
Delay the emission of the terminal events of this Nono by the given time amount.- Parameters:
delay- the delay amountunit- the time unit- Returns:
- the new Nono instance
-
delay
@SchedulerSupport("custom") public final Nono delay(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Delay the emission of the terminal events of this Nono by the given time amount.- Parameters:
delay- the delay amountunit- the time unitscheduler- the scheduler to wait on- Returns:
- the new Nono instance
-
delaySubscription
public final Nono delaySubscription(Publisher<?> other)
Delays the actual subscription to this Nono until the other Publisher signals an item or completes.- Parameters:
other- the other Publisher to await a signal from- Returns:
- the new Nono instance
-
delaySubscription
public final Nono delaySubscription(long delay, java.util.concurrent.TimeUnit unit)
Delays the actual subscription to this Nono until the given time passes.- Parameters:
delay- the delay amountunit- the time unit- Returns:
- the new Nono instance
-
delaySubscription
public final Nono delaySubscription(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Delays the actual subscription to this Nono until the given time passes.- Parameters:
delay- the delay amountunit- the time unitscheduler- the scheduler to wait on- Returns:
- the new Nono instance
-
timeout
public final Nono timeout(long timeout, java.util.concurrent.TimeUnit unit)
Signals a TimeoutException if this Nono doesn't complete within the specified timeout.- Parameters:
timeout- the timeout amountunit- the time unit- Returns:
- the new Nono instance
-
timeout
public final Nono timeout(long timeout, java.util.concurrent.TimeUnit unit, Nono fallback)
Switches to the fallback Nono if this Nono doesn't complete within the specified timeout.- Parameters:
timeout- the timeout amountunit- the time unitfallback- the Nono to switch to if this Nono times out- Returns:
- the new Nono instance
-
timeout
public final Nono timeout(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Signals a TimeoutException if this Nono doesn't complete within the specified timeout.- Parameters:
timeout- the timeout amountunit- the time unitscheduler- the scheduler to wait on- Returns:
- the new Nono instance
-
timeout
public final Nono timeout(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler, Nono fallback)
Switches to the fallback Nono if this Nono doesn't complete within the specified timeout.- Parameters:
timeout- the timeout amountunit- the time unitscheduler- the scheduler to wait onfallback- the Nono to switch to if this Nono times out- Returns:
- the new Nono instance
-
timeout
public final Nono timeout(Publisher<?> other)
Signal a TimeoutException if the other Publisher signals an item or completes before this Nono completes.- Parameters:
other- the other Publisher instance- Returns:
- the new Nono instance
-
timeout
public final Nono timeout(Publisher<?> other, Nono fallback)
Switch to the fallback Nono if the other Publisher signals an item or completes before this Nono completes.- Parameters:
other- the other Publisher instancefallback- the fallback Nono instance- Returns:
- the new Nono instance
-
onErrorComplete
public final Nono onErrorComplete()
If this Nono signals an error, signal an onComplete instead.- Returns:
- the new Nono instance
-
onErrorResumeNext
public final Nono onErrorResumeNext(Function<? super java.lang.Throwable,? extends Nono> errorHandler)
If this Nono signals an error, subscribe to the fallback Nono returned by the error handler function.- Parameters:
errorHandler- the function called with the error and should return a Nono to resume with.- Returns:
- the new Nono instance
-
mapError
public final Nono mapError(Function<? super java.lang.Throwable,? extends java.lang.Throwable> mapper)
Maps the upstream error into another Throwable via a function.- Parameters:
mapper- the function that receives the upstream Throwable and should return another Throwable to be emitted to downstream- Returns:
- the new Nono instance
-
flatMap
public final <T> Flowable<T> flatMap(Function<? super java.lang.Throwable,? extends Publisher<? extends T>> onErrorMapper, Supplier<? extends Publisher<? extends T>> onCompleteMapper)
Maps the upstream completion or error into a Publisher and emit its events as a Flowable.- Type Parameters:
T- the value type- Parameters:
onErrorMapper- the function that receives the upstream error and returns a Publisher to emit events ofonCompleteMapper- the supplier that returns a Publisher to emit events of- Returns:
- the new Flowable instance
-
compose
public final Nono compose(Function<? super Nono,? extends Nono> composer)
Compose operators fluently via a function callback that returns a Nono for this Nono.- Parameters:
composer- the function receiving this and returns a Nono- Returns:
- the Nono returned by the function
-
to
public final <R> R to(Function<? super Nono,R> converter)
Fluently convert this Nono via a function callback into some type.- Type Parameters:
R- the result value type- Parameters:
converter- the function receiving this and returning a value- Returns:
- the value returned by the converter
-
lift
public final Nono lift(Function<Subscriber<? super java.lang.Void>,Subscriber<? super java.lang.Void>> lifter)
Transform the downstream's Subscriber into a Subscriber for the upstream via a function.- Parameters:
lifter- the function receiving the downstream Subscriber and returns a Subscriber for the upstream.- Returns:
- the new Nono instance
-
toFlowable
public final <T> Flowable<T> toFlowable()
Convert this Nono instance into a Flowable that only terminates.- Type Parameters:
T- the value type- Returns:
- the new Flowable instance
-
toObservable
public final <T> Observable<T> toObservable()
Convert this Nono instance into an Observable that only terminates.- Type Parameters:
T- the value type- Returns:
- the new Observable instance
-
toCompletable
public final Completable toCompletable()
Convert this Nono instance into a Completable.- Returns:
- the new Completable instance
-
toMaybe
public final <T> Maybe<T> toMaybe()
Convert this Nono instance into a Maybe that only terminates.- Type Parameters:
T- the value type- Returns:
- the new Maybe instance
-
toPerhaps
public final <T> Perhaps<T> toPerhaps()
Convert this Nono instance into a Perhaps that only terminates.- Type Parameters:
T- the value type- Returns:
- the new Perhap instance
-
subscribeOn
public final Nono subscribeOn(Scheduler scheduler)
Subscribes to the upstream on the specified Scheduler.- Parameters:
scheduler- the Scheduler to subscribe on- Returns:
- the new Nono instance
-
observeOn
public final Nono observeOn(Scheduler scheduler)
Observes the onError and onComplete events on the specified Scheduler.- Parameters:
scheduler- the Scheduler to emit terminal events on- Returns:
- the new Nono instance
-
unsubscribeOn
public final Nono unsubscribeOn(Scheduler scheduler)
If the downstream cancels the sequence, the cancellation towards the upstream will happen on the specified Scheduler.- Parameters:
scheduler- the Scheduler to cancel on- Returns:
- the new Nono instance
-
doOnComplete
public final Nono doOnComplete(Action onComplete)
Executes a callback when the upstream completes normally.- Parameters:
onComplete- the consumer called before the completion event is emitted to the downstream.- Returns:
- the new Nolo instance
-
doOnError
public final Nono doOnError(Consumer<? super java.lang.Throwable> onError)
Executes a callback when the upstream signals an error.- Parameters:
onError- the consumer called before the error is emitted to the downstream- Returns:
- the new Nolo instance
-
doOnSubscribe
public final Nono doOnSubscribe(Consumer<? super Subscription> onSubscribe)
Executes a callback when the upstream calls onSubscribe.- Parameters:
onSubscribe- the consumer called with the upstream Subscription- Returns:
- the new Nolo instance
-
doOnRequest
public final Nono doOnRequest(LongConsumer onRequest)
Executes the callback when the downstream requests from this Nolo.- Parameters:
onRequest- the callback called with the request amount- Returns:
- the new Nolo instance
-
doAfterTerminate
public final Nono doAfterTerminate(Action onAfterTerminate)
Executes the callback after this Nono terminates and the downstream is notified.- Parameters:
onAfterTerminate- the callback to call after the downstream is notified- Returns:
- the new Nono instance
-
doFinally
public final Nono doFinally(Action onFinally)
Executes the callback exactly if the upstream terminates or the downstream cancels the sequence.- Parameters:
onFinally- the action to call- Returns:
- the new Nono instance
-
doOnCancel
public final Nono doOnCancel(Action onCancel)
Executes the callback if the downstream cancels the sequence.- Parameters:
onCancel- the action to call- Returns:
- the new Nono instance
-
repeat
public final Nono repeat()
Repeatedly run this Nono indefinitely.- Returns:
- the new Nono instance
-
repeat
public final Nono repeat(long times)
Repeatedly run this Nono at most the given number of times.- Parameters:
times- the repeat count- Returns:
- the new Nono instance
-
repeat
public final Nono repeat(BooleanSupplier stop)
Repeat until the given BooleanSupplier returns true.- Parameters:
stop- the boolean supplier to return null to stop repeating- Returns:
- the new Nono instance
-
repeatWhen
public final Nono repeatWhen(Function<? super Flowable<java.lang.Object>,? extends Publisher<?>> handler)
Repeat when the Publisher returned by the handler function signals a value or terminate accordingly.- Parameters:
handler- the Function that receives a Flowable that emits an object when this Nono completes normally and should return a Publisher that if signals a normal item, it triggers a resubscription to this Nono.- Returns:
- the new Nono instance
-
retry
public final Nono retry()
Repeatedly run this Nono indefinitely if it fails.- Returns:
- the new Nono instance
-
retry
public final Nono retry(long times)
Repeatedly run this Nono at most the given number of times if it fails.- Parameters:
times- the repeat count- Returns:
- the new Nono instance
-
retry
public final Nono retry(Predicate<? super java.lang.Throwable> predicate)
Retry a failed Nono if the predicate return true.- Parameters:
predicate- the predicate receiving the failure Throwable and returns true to trigger a retry.- Returns:
- the new Nono instance
-
retryWhen
public final Nono retryWhen(Function<? super Flowable<java.lang.Throwable>,? extends Publisher<?>> handler)
Retry this Nono when the Publisher returned by the handler function signals a normal item or terminate if the Publisher terminates.- Parameters:
handler- the Function that receives a Flowable of the failure Throwable and returns a Publisher that if signals a normal item, it triggers a resubscription.- Returns:
- the new Nono instance
-
hide
public final Nono hide()
Hides the identity of this Nono.This also breaks optimizations such as operator fusion - useful when diagnosing issues.
- Returns:
- the new Nono instance
-
takeUntil
public final Nono takeUntil(Publisher<?> other)
Run this Nono and cancel it when the other Publisher signals an item or completes.- Parameters:
other- the other Publisher- Returns:
- the new Nono instance
-
cache
public final Nono cache()
Caches the terminal event of the upstream Nono and relays/replays it to Subscribers.- Returns:
- the new Nono instance
- Since:
- 0.14.1
-
subscribe
public final void subscribe(Subscriber<? super java.lang.Void> s)
-
subscribeActual
protected abstract void subscribeActual(Subscriber<? super java.lang.Void> s)
Implement this method to signal the terminal events to the given subscriber.- Parameters:
s- the downstream subscriber, not null
-
subscribeWith
@SchedulerSupport("none") public final <T,E extends Subscriber<T>> E subscribeWith(E subscriber)
Subscribe with the given subscriber and return the same subscriber, allowing chaining methods on it or fluently reusing the instance.- Type Parameters:
T- the target value type of the subscriberE- the subscriber's (sub)type- Parameters:
subscriber- the subscriber to subscribe with, not null- Returns:
- the subscriber
-
test
@SchedulerSupport("none") public final TestSubscriber<java.lang.Void> test()
Create a TestSubscriber, subscribe it to this Nono and return the TestSubscriber itself.- Returns:
- the TestSubscriber created
-
test
@SchedulerSupport("none") public final TestSubscriber<java.lang.Void> test(boolean cancelled)
Create a TestSubscriber, optionally cancel it, subscribe it to this Nono and return the TestSubscriber itself.- Parameters:
cancelled- shoud the TestSubscriber be cancelled before the subscription- Returns:
- the TestSubscriber created
-
blockingAwait
@SchedulerSupport("none") public final java.lang.Throwable blockingAwait()
Blockingly await indefinitely the termination of this Nono and return the Throwable if this Nono terminated with an error, null otherwise.- Returns:
- the Throwable error of the Nono, null if completed normally
-
blockingAwait
@SchedulerSupport("none") public final java.lang.Throwable blockingAwait(long timeout, java.util.concurrent.TimeUnit unit)
Blockingly await for the given timeout the termination of this Nono and return the Throwable if this Nono terminated with an error, null otherwise.- Parameters:
timeout- the timeout valueunit- the time unit- Returns:
- the Throwable error of the Nono, null if completed normally
-
subscribe
public final Disposable subscribe()
Subscribe to this Nono and ignore the events it produces.- Returns:
- the Disposable to cancel the subscription
- Since:
- 0.13.0
-
subscribe
@SchedulerSupport("none") public final Disposable subscribe(Action onComplete)
Subscribe to this Nono and execute the given action if this Nono completes.- Parameters:
onComplete- the callback Action to be called when this Nono completes- Returns:
- the Disposable to cancel the subscription
-
subscribe
@SchedulerSupport("none") public final Disposable subscribe(Action onComplete, Consumer<? super java.lang.Throwable> onError)
Subscribe to this Nono and execute the given action if this Nono completes or call the consumer if this Nono terminates with an error.- Parameters:
onComplete- the callback Action to be called when this Nono completesonError- the callback Consumer to be called with the terminal error.- Returns:
- the Disposable to cancel the subscription
-
blockingSubscribe
public final void blockingSubscribe()
Block until this Nono terminates and ignore the actual events.- Since:
- 0.13.0
-
blockingSubscribe
public final void blockingSubscribe(Action onComplete)
Block until this Nono completes and call the Action on the thread where the blocking happens.- Parameters:
onComplete- the Action to call when this Nono terminates
-
blockingSubscribe
public final void blockingSubscribe(Action onComplete, Consumer<? super java.lang.Throwable> onError)
Block until this Nono terminates and call the Action or Consumer depending on the terminal event on the thread where the blocking happens.- Parameters:
onComplete- the Action to call when this Nono completesonError- the Consumer to call when this Nono terminates with an error
-
toFuture
public final java.util.concurrent.Future<java.lang.Void> toFuture()
Converts this Nono into a Future and signals its single value.- Returns:
- the new Future instance
-
-