public interface RxGetter<T> extends IObservable<T>, Supplier<T>
get()
method or by listening to its Observable
.
RxGetter
's Observable
has the semantics of a
BehaviorSubject
, meaning that as soon as a listener
subscribes to the Observable
, it will emit the current value.
Any time the value changes, RxGetter
's Observable
will notify
of the change. If the value did not change (e.g. a field is
set to its current value, which produces no change) then the
Observable
will not fire.
Modifier and Type | Method and Description |
---|---|
static <T1,T2,R> RxGetter<R> |
combineLatest(RxGetter<? extends T1> t,
RxGetter<? extends T2> u,
BiFunction<? super T1,? super T2,? extends R> combine)
Creates an
RxGetter which combines two RxGetter s using the BiFunction combine . |
static <T> RxGetter<T> |
from(Observable<T> observableUnfiltered,
T initialValue)
Creates an
RxGetter from the given Observable and initialValue . |
default <R> RxGetter<R> |
map(Function<? super T,? extends R> mapper)
Maps an
RxGetter to a new RxGetter by applying the mapper function
to all of its values. |
asObservable
default <R> RxGetter<R> map(Function<? super T,? extends R> mapper)
RxGetter
to a new RxGetter
by applying the mapper
function
to all of its values.
If the Observable
of the source RxGetter
changes, but the
Function<T, R> mapper
collapses these values to produce
no change, then the mapped Observable
shall not emit a new value.
("A", "B", "C") -> map(String::length) = (1, 1, 1)
("A", "B", "C") -> map(String::length) = (1)
static <T> RxGetter<T> from(Observable<T> observableUnfiltered, T initialValue)
RxGetter
from the given Observable
and initialValue
.static <T1,T2,R> RxGetter<R> combineLatest(RxGetter<? extends T1> t, RxGetter<? extends T2> u, BiFunction<? super T1,? super T2,? extends R> combine)
RxGetter
which combines two RxGetter
s using the BiFunction combine
.
As with map(java.util.function.Function<? super T, ? extends R>)
, the observable only emits a new value if its value has changed.