M
- The message type. This may be Void
if no message need be
sent.public interface Observable<M>
Modifier and Type | Method and Description |
---|---|
default Observable<java.util.List<M>> |
aggregateBackpressure() |
default Observable<java.util.List<M>> |
aggregateBackpressure(long toCapacity) |
default <R,A> java.util.concurrent.CompletableFuture<R> |
collect(java.util.stream.Collector<? super M,A,? extends R> collector) |
default <R,A> Observable<R> |
collectBackpressure(java.util.stream.Collector<? super M,A,? extends R> collector)
Introduce backpressure by collecting messages until a request is made
downstream, then forwarding the collection.
|
default <T> Observable<T> |
compose(java.util.function.Function<Observable<? super M>,Observable<? extends T>> transformation)
Derive a new observable by application of the given function.
|
static <M> Observable<M> |
concat(java.util.Collection<? extends Observable<? extends M>> observables) |
static <M> Observable<M> |
concat(Observable<? extends M>... observables) |
default <T> Observable<T> |
concatMap(java.util.function.Function<? super M,? extends Observable<? extends T>> mapping)
|
default Observable<M> |
dropWhile(java.util.function.Predicate<? super M> condition)
Derive an observable which completes and disposes itself after receiving a
message which matches the given condition.
|
static <T> Observable<T> |
empty() |
default Observable<M> |
executeOn(java.util.concurrent.Executor executor)
Derive an observable which re-emits messages on the given executor.
|
static <M> ObservableValue<M> |
failingValue(java.lang.Throwable failure) |
default Observable<M> |
filter(java.util.function.Predicate<? super M> condition)
Derive an observable which passes along only those messages which match the
given condition.
|
default <T> Observable<T> |
flatMap(java.util.function.Function<? super M,? extends Observable<? extends T>> mapping,
RequestAllocator requestAllocator)
Derive an observable which maps each message to an intermediate observable,
then combines those intermediate observables into one.
|
default M |
get()
Block until we either receive the next message event of the next failure
event.
|
default java.util.concurrent.CompletableFuture<M> |
getNext()
Block until we either receive the next message event of the next failure
event.
|
default <T> Observable<T> |
map(java.util.function.Function<? super M,? extends T> mapping)
Derive an observable which transforms messages according to the given
mapping.
|
default Observable<Observable<M>> |
materialize() |
static <M> Observable<M> |
merge(java.util.Collection<? extends Observable<? extends M>> observables) |
static <M> Observable<M> |
merge(Observable<? extends M>... observables) |
default <T> Observable<T> |
mergeMap(java.util.function.Function<? super M,? extends Observable<? extends T>> mapping)
A common case of
flatMap(Function, RequestAllocator) using
balanced request allocation . |
default Disposable |
observe()
As
observe(Observer) with an empty observer. |
Disposable |
observe(Observer<? super M> observer)
Observers added will receive messages from this Observable.
|
static <M> Observable<M> |
of(java.util.Collection<? extends M> messages) |
static <M> Observable<M> |
of(M... messages) |
static <M> Observable<M> |
of(java.util.Optional<? extends M> messages) |
default <R> java.util.concurrent.CompletableFuture<R> |
reduce(java.util.function.Supplier<R> identity,
java.util.function.BiFunction<R,? super M,R> accumulator) |
default Observable<M> |
reduceBackpressure(java.util.function.BinaryOperator<M> accumulator)
Introduce backpressure by reducing messages until a request is made
downstream, then forwarding the reduction.
|
default <R> Observable<R> |
reduceBackpressure(java.util.function.Function<? super M,? extends R> initial,
java.util.function.BiFunction<? super R,? super M,? extends R> accumulator)
Introduce backpressure by reducing messages until a request is made
downstream, then forwarding the reduction.
|
default <R> Observable<R> |
reduceBackpressure(java.util.function.Supplier<? extends R> identity,
java.util.function.BiFunction<? super R,? super M,? extends R> accumulator)
Introduce backpressure by reducing messages until a request is made
downstream, then forwarding the reduction.
|
default Observable<M> |
repeating() |
default Observable<M> |
requestNext() |
default Observable<M> |
requestUnbounded() |
default Observable<M> |
retrying() |
default Observable<M> |
softReference()
Derive an observable which automatically disposes of observers at some point
after they are no longer softly reachable.
|
default <O> Observable<OwnedMessage<O,M>> |
softReference(O owner)
Derive an observable which automatically disposes of observers at some point
after the given owner is no longer softly reachable.
|
default Observable<M> |
synchronize() |
default Observable<M> |
synchronize(java.lang.Object mutex) |
default Observable<M> |
takeWhile(java.util.function.Predicate<? super M> condition)
Derive an observable which completes and disposes itself after receiving a
message which matches the given condition.
|
default Observable<M> |
then(Observer<? super M> action)
Derive an observable which passes events to the given observer directly
before passing them downstream.
|
default Observable<M> |
thenAfter(Observer<? super M> action)
Derive an observable which passes events to the given observer directly after
passing them downstream.
|
static <M> java.util.stream.Collector<? extends M,?,Observable<M>> |
toObservable()
A collector which can be applied to a
Stream to derive a cold
observable. |
default ObservableValue<M> |
toValue() |
default ObservableValue<M> |
toValue(M initial) |
default ObservableValue<M> |
toValue(java.lang.Throwable initialProblem) |
default java.util.Optional<M> |
tryGet() |
static <T,U extends T> |
upcast(Observable<U> from) |
static <M> ObservableValue<M> |
value(M value) |
default Observable<M> |
weakReference()
Derive an observable which automatically disposes of observers at some point
after they are no longer weakly reachable.
|
default <O> Observable<OwnedMessage<O,M>> |
weakReference(O owner)
Derive an observable which automatically disposes of observers at some point
after the given owner is no longer weakly reachable.
|
Disposable observe(Observer<? super M> observer)
observer
- an observer to adddefault Disposable observe()
observe(Observer)
with an empty observer.default java.util.concurrent.CompletableFuture<M> getNext()
MissingValueException
.MissingValueException
- If a failure or completion event is received before the next
message event. In the former case the cause will be the failure
throwable, in the latter case an instance of
AlreadyCompletedException
.default M get()
MissingValueException
.MissingValueException
- If a failure or completion event is received before the next
message event. In the former case the cause will be the failure
throwable, in the latter case an instance of
AlreadyCompletedException
.default java.util.Optional<M> tryGet()
default <T> Observable<T> compose(java.util.function.Function<Observable<? super M>,Observable<? extends T>> transformation)
T
- the type of the resulting observabletransformation
- the transformation function to apply to the observablestatic <T,U extends T> Observable<T> upcast(Observable<U> from)
static <M> java.util.stream.Collector<? extends M,?,Observable<M>> toObservable()
Stream
to derive a cold
observable.M
- the type of the observabledefault Observable<M> then(Observer<? super M> action)
action
- an observer representing the action to takedefault Observable<M> thenAfter(Observer<? super M> action)
action
- an observer representing the action to takedefault Observable<M> requestUnbounded()
default Observable<M> requestNext()
default Observable<M> retrying()
default Observable<M> repeating()
default Observable<Observable<M>> materialize()
default ObservableValue<M> toValue()
default ObservableValue<M> toValue(M initial)
default ObservableValue<M> toValue(java.lang.Throwable initialProblem)
default Observable<M> weakReference()
default <O> Observable<OwnedMessage<O,M>> weakReference(O owner)
Care should be taken not to refer to the owner directly in any observer
logic, as this will create a strong reference to the owner, preventing it
from becoming unreachable. For this reason, the message is transformed into
an OwnedMessage
, which may create references to the owner on demand
within observer logic without retainment.
O
- the type of the owning objectowner
- the owning referent objectdefault Observable<M> softReference()
default <O> Observable<OwnedMessage<O,M>> softReference(O owner)
Care should be taken not to refer to the owner directly in any observer
logic, as this will create a strong reference to the owner, preventing it
from becoming unreachable. For this reason, the message is transformed into
an OwnedMessage
, which may create references to the owner on demand
within observer logic without retainment.
O
- the type of the owning objectowner
- the owning referent objectdefault Observable<M> executeOn(java.util.concurrent.Executor executor)
executor
- the target executordefault <T> Observable<T> map(java.util.function.Function<? super M,? extends T> mapping)
T
- the type of the derived observablemapping
- the mapping functiondefault Observable<M> filter(java.util.function.Predicate<? super M> condition)
condition
- the terminating conditiondefault Observable<M> takeWhile(java.util.function.Predicate<? super M> condition)
condition
- the terminating conditiondefault Observable<M> dropWhile(java.util.function.Predicate<? super M> condition)
condition
- the terminating conditiondefault Observable<M> synchronize()
default Observable<M> synchronize(java.lang.Object mutex)
default <T> Observable<T> mergeMap(java.util.function.Function<? super M,? extends Observable<? extends T>> mapping)
flatMap(Function, RequestAllocator)
using
balanced request allocation
.
An unbounded request is made to the upstream observable, so it is not required to support backpressure.
The intermediate observables are not required to support backpressure, as an unbounded request will be made to them and the downstream observable will forward every message as soon as it is available. Because of this, The downstream observable does not support backpressure.
T
- the resulting observable message typemapping
- the terminating conditiondefault <T> Observable<T> concatMap(java.util.function.Function<? super M,? extends Observable<? extends T>> mapping)
T
- the resulting observable message typemapping
- the terminating conditiondefault <T> Observable<T> flatMap(java.util.function.Function<? super M,? extends Observable<? extends T>> mapping, RequestAllocator requestAllocator)
The intermediate observables accept requests from downstream until they are
complete. Requests are allocated to the intermediate observables by the given
request allocation strategy
.
The upstream observable is not required to support backpressure. If a request is made downstream when there are no intermediate observables to fulfill that request, another message is requested from upstream.
The resulting observable supports backpressure if and only if the intermediate observables support backpressure.
T
- the resulting observable message typemapping
- the terminating conditionrequestAllocator
- the strategy for allocating downstream requests to upstream
observationsdefault <R> java.util.concurrent.CompletableFuture<R> reduce(java.util.function.Supplier<R> identity, java.util.function.BiFunction<R,? super M,R> accumulator)
default <R> Observable<R> reduceBackpressure(java.util.function.Supplier<? extends R> identity, java.util.function.BiFunction<? super R,? super M,? extends R> accumulator)
R
- the resulting reduction typeidentity
- the identity value for the accumulating functionaccumulator
- an associative, non-interfering, stateless function for combining
two valuesdefault <R> Observable<R> reduceBackpressure(java.util.function.Function<? super M,? extends R> initial, java.util.function.BiFunction<? super R,? super M,? extends R> accumulator)
R
- the resulting reduction typeinitial
- the initial value for the accumulating functionaccumulator
- an associative, non-interfering, stateless function for combining
two valuesdefault Observable<M> reduceBackpressure(java.util.function.BinaryOperator<M> accumulator)
accumulator
- an associative, non-interfering, stateless function for combining
two valuesdefault <R,A> java.util.concurrent.CompletableFuture<R> collect(java.util.stream.Collector<? super M,A,? extends R> collector)
default <R,A> Observable<R> collectBackpressure(java.util.stream.Collector<? super M,A,? extends R> collector)
R
- the resulting collection typeA
- the intermediate collection typecollector
- the collector to apply to incoming messagesdefault Observable<java.util.List<M>> aggregateBackpressure()
default Observable<java.util.List<M>> aggregateBackpressure(long toCapacity)
@SafeVarargs static <M> Observable<M> of(M... messages)
static <M> Observable<M> of(java.util.Collection<? extends M> messages)
static <M> Observable<M> of(java.util.Optional<? extends M> messages)
@SafeVarargs static <M> Observable<M> merge(Observable<? extends M>... observables)
static <M> Observable<M> merge(java.util.Collection<? extends Observable<? extends M>> observables)
@SafeVarargs static <M> Observable<M> concat(Observable<? extends M>... observables)
static <M> Observable<M> concat(java.util.Collection<? extends Observable<? extends M>> observables)
static <M> ObservableValue<M> failingValue(java.lang.Throwable failure)
static <M> ObservableValue<M> value(M value)
static <T> Observable<T> empty()