public interface RxBox<T> extends RxGetter<T>, Box<T>
Modifier and Type | Method and Description |
---|---|
default RxBox<T> |
enforce(Function<? super T,? extends T> enforcer)
Provides a mechanism for enforcing an invariant on an existing
`RxBox`.
|
static <T> RxBox<T> |
from(RxGetter<T> getter,
Consumer<T> setter)
Creates an `RxBox` which implements the "getter" part with `RxGetter`, and the setter part with `Consumer`.
|
default <R> RxBox<R> |
map(Converter<T,R> converter)
Maps one `RxBox` to another `RxBox`.
|
static <T> RxBox<T> |
of(T initial)
Creates an `RxBox` with the given initial value.
|
default RxGetter<T> |
readOnly()
Returns a read-only version of this `RxBox`.
|
combineLatest, from, fromVolatile, map
asObservable, subscribe, wrap
default RxBox<T> enforce(Function<? super T,? extends T> enforcer)
RxLockBox
can still be
modified atomically).
Conflicting calls to `enforce` can cause an infinite loop, see Breaker
for a possible solution.
```java
// this will not end well...
RxBox.of(1).enforce(Math::abs).enforce(i -> -Math.abs(i));
```static <T> RxBox<T> of(T initial)