Class ObservableUtil

java.lang.Object
org.drasyl.util.ObservableUtil

public class ObservableUtil extends Object
Utility class for operations on Observables.
  • Method Details

    • pairWithPreviousObservable

      public static <T> io.reactivex.rxjava3.core.Observable<Pair<T,T>> pairWithPreviousObservable(io.reactivex.rxjava3.core.Observable<T> observable)
      Creates an Observable to pair up the current and previous items.
       Source:
         +---+  +---+  +---+
       --+ A +--+ B +--+ C +->
         +---+  +---+  +---+
      
       pairWithPreviousObservable:
         +---+  +---+  +---+
       --+ A +--+ B +--+ C +->
         | ⊥ |  | A |  | B |
         +---+  +---+  +---+
       
      Adapted from http://www.zerobugbuild.com/?p=213
      Type Parameters:
      T - the common element type
      Parameters:
      observable - Observable whose current and previous items are to be paired.
      Returns:
      the new Observable instance