Package hu.akarnokd.rxjava3.expr
Class StatementFlowable
- java.lang.Object
-
- hu.akarnokd.rxjava3.expr.StatementFlowable
-
public final class StatementFlowable extends java.lang.ObjectImperative statements expressed as Flowable operators.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Flowable<T>doWhile(Publisher<? extends T> source, BooleanSupplier postCondition)Return an Flowable that re-emits the emissions from the source Flowable, and then re-subscribes to the source long as a condition is true.static <R> Flowable<R>ifThen(BooleanSupplier condition, Publisher<? extends R> then)Return an Flowable that emits the emissions from a specified Flowable if a condition evaluates to true, otherwise return an empty Flowable.static <R> Flowable<R>ifThen(BooleanSupplier condition, Publisher<? extends R> then, Flowable<? extends R> orElse)Return an Flowable that emits the emissions from one specified Flowable if a condition evaluates to true, or from another specified Flowable otherwise.static <R> Flowable<R>ifThen(BooleanSupplier condition, Publisher<? extends R> then, Scheduler scheduler)Return an Flowable that emits the emissions from a specified Flowable if a condition evaluates to true, otherwise return an empty Flowable that runs on a specified Scheduler.static <K,R>
Flowable<R>switchCase(Supplier<? extends K> caseSelector, java.util.Map<? super K,? extends Publisher<? extends R>> mapOfCases)Return a particular one of several possible Observables based on a case selector.static <K,R>
Flowable<R>switchCase(Supplier<? extends K> caseSelector, java.util.Map<? super K,? extends Publisher<? extends R>> mapOfCases, Scheduler scheduler)Return a particular one of several possible Observables based on a case selector and run it on the designated scheduler.static <K,R>
Flowable<R>switchCase(Supplier<? extends K> caseSelector, java.util.Map<? super K,? extends Publisher<? extends R>> mapOfCases, Publisher<? extends R> defaultCase)Return a particular one of several possible Observables based on a case selector, or a default Flowable if the case selector does not map to a particular one.static <T> Flowable<T>whileDo(Publisher<? extends T> source, BooleanSupplier preCondition)Return an Flowable that re-emits the emissions from the source Flowable as long as the condition is true before the first or subsequent subscribe() calls.
-
-
-
Method Detail
-
switchCase
public static <K,R> Flowable<R> switchCase(Supplier<? extends K> caseSelector, java.util.Map<? super K,? extends Publisher<? extends R>> mapOfCases)
Return a particular one of several possible Observables based on a case selector.
- Type Parameters:
K- the case key typeR- the result value type- Parameters:
caseSelector- the function that produces a case key when an Observer subscribesmapOfCases- a map that maps a case key to an Flowable- Returns:
- a particular Flowable chosen by key from the map of Observables, or an empty Flowable if no Flowable matches the key
-
switchCase
public static <K,R> Flowable<R> switchCase(Supplier<? extends K> caseSelector, java.util.Map<? super K,? extends Publisher<? extends R>> mapOfCases, Scheduler scheduler)
Return a particular one of several possible Observables based on a case selector and run it on the designated scheduler.
- Type Parameters:
K- the case key typeR- the result value type- Parameters:
caseSelector- the function that produces a case key when an Observer subscribesmapOfCases- a map that maps a case key to an Flowablescheduler- the scheduler where the empty observable is observed- Returns:
- a particular Flowable chosen by key from the map of Observables, or an empty Flowable if no Flowable matches the key, but one that runs on the designated scheduler in either case
-
switchCase
public static <K,R> Flowable<R> switchCase(Supplier<? extends K> caseSelector, java.util.Map<? super K,? extends Publisher<? extends R>> mapOfCases, Publisher<? extends R> defaultCase)
Return a particular one of several possible Observables based on a case selector, or a default Flowable if the case selector does not map to a particular one.
- Type Parameters:
K- the case key typeR- the result value type- Parameters:
caseSelector- the function that produces a case key when an Observer subscribesmapOfCases- a map that maps a case key to an FlowabledefaultCase- the default Flowable if themapOfCasesdoesn't contain a value for the key returned by thecaseSelector- Returns:
- a particular Flowable chosen by key from the map of Observables, or the default case if no Flowable matches the key
-
doWhile
public static <T> Flowable<T> doWhile(Publisher<? extends T> source, BooleanSupplier postCondition)
Return an Flowable that re-emits the emissions from the source Flowable, and then re-subscribes to the source long as a condition is true.
- Type Parameters:
T- the value type- Parameters:
source- the source Flowable to work withpostCondition- the post condition to test after the source Flowable completes- Returns:
- an Flowable that replays the emissions from the source Flowable, and then continues to replay them so long as the post condition is true
-
whileDo
public static <T> Flowable<T> whileDo(Publisher<? extends T> source, BooleanSupplier preCondition)
Return an Flowable that re-emits the emissions from the source Flowable as long as the condition is true before the first or subsequent subscribe() calls.
- Type Parameters:
T- the value type- Parameters:
source- the source Flowable to work withpreCondition- the condition to evaluate before subscribing to or replaying the source Flowable- Returns:
- an Flowable that replays the emissions from the source
Flowable so long as
preConditionis true
-
ifThen
public static <R> Flowable<R> ifThen(BooleanSupplier condition, Publisher<? extends R> then)
Return an Flowable that emits the emissions from a specified Flowable if a condition evaluates to true, otherwise return an empty Flowable.
- Type Parameters:
R- the result value type- Parameters:
condition- the condition that decides whether to emit the emissions from thethenFlowablethen- the Flowable sequence to emit to ifconditionistrue- Returns:
- an Flowable that mimics the
thenFlowable if theconditionfunction evaluates to true, or an empty Flowable otherwise
-
ifThen
public static <R> Flowable<R> ifThen(BooleanSupplier condition, Publisher<? extends R> then, Scheduler scheduler)
Return an Flowable that emits the emissions from a specified Flowable if a condition evaluates to true, otherwise return an empty Flowable that runs on a specified Scheduler.
- Type Parameters:
R- the result value type- Parameters:
condition- the condition that decides whether to emit the emissions from thethenFlowablethen- the Flowable sequence to emit to ifconditionistruescheduler- the Scheduler on which the empty Flowable runs if the in case the condition returns false- Returns:
- an Flowable that mimics the
thenFlowable if theconditionfunction evaluates to true, or an empty Flowable running on the specified Scheduler otherwise
-
ifThen
public static <R> Flowable<R> ifThen(BooleanSupplier condition, Publisher<? extends R> then, Flowable<? extends R> orElse)
Return an Flowable that emits the emissions from one specified Flowable if a condition evaluates to true, or from another specified Flowable otherwise.
- Type Parameters:
R- the result value type- Parameters:
condition- the condition that decides which Flowable to emit the emissions fromthen- the Flowable sequence to emit to ifconditionistrueorElse- the Flowable sequence to emit to ifconditionisfalse- Returns:
- an Flowable that mimics either the
thenororElseObservables depending on a condition function
-
-