Beispiel #1
0
 /**
  * Creates a size-bounded replay relay.
  *
  * <p>In this setting, the {@code ReplayRelay} holds at most {@code size} items in its internal
  * buffer and discards the oldest item.
  *
  * <p>If an observer subscribes while the {@code ReplayRelay} is active, it will observe all items
  * in the buffer at that point in time and each item observed afterwards, even if the buffer
  * evicts items due to the size constraint in the mean time. In other words, once an Observer
  * subscribes, it will receive items without gaps in the sequence.
  *
  * @param <T> the type of items observed and emitted by the Relay
  * @param size the maximum number of buffered items
  * @return the created relay
  */
 public static <T> ReplayRelay<T> createWithSize(int size) {
   final BoundedState<T> state =
       new BoundedState<T>(
           new SizeEvictionPolicy(size), UtilityFunctions.identity(), UtilityFunctions.identity());
   return createWithState(state, new DefaultOnAdd<T>(state));
 }
Beispiel #2
0
 /* public */
 static <T> ReplayRelay<T> createUnbounded() {
   final BoundedState<T> state =
       new BoundedState<T>(
           new EmptyEvictionPolicy(), UtilityFunctions.identity(), UtilityFunctions.identity());
   return createWithState(state, new DefaultOnAdd<T>(state));
 }