Class GroupedObservable<K,T>

java.lang.Object
rx.Observable<T>
rx.observables.GroupedObservable<K,T>
Type Parameters:
K - the type of the key
T - the type of the items emitted by the GroupedObservable
Direct Known Subclasses:
OperatorGroupBy.GroupedUnicast

public class GroupedObservable<K,T> extends Observable<T>
An Observable that has been grouped by key, the value of which can be obtained with getKey().

Note: A GroupedObservable will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those GroupedObservables that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator like take(0) to them.

See Also:
  • Field Details

    • key

      private final K key
  • Constructor Details

  • Method Details

    • from

      public static <K, T> GroupedObservable<K,T> from(K key, Observable<T> o)
      Converts an Observable into a GroupedObservable with a particular key.
      Type Parameters:
      K - the key type
      T - the value type
      Parameters:
      key - the key to identify the group of items emitted by this GroupedObservable
      o - the Observable to convert
      Returns:
      a GroupedObservable representation of o, with key key
    • create

      public static <K, T> GroupedObservable<K,T> create(K key, Observable.OnSubscribe<T> f)
      Returns an Observable that will execute the specified function when a Subscriber subscribes to it.

      Write the function you pass to create so that it behaves as an Observable: It should invoke the Subscriber's onNext, onError, and onCompleted methods appropriately.

      A well-formed Observable must invoke either the Subscriber's onCompleted method exactly once or its onError method exactly once.

      See Rx Design Guidelines (PDF) for detailed information.

      Scheduler:
      create does not operate by default on a particular Scheduler.
      Type Parameters:
      K - the type of the key
      T - the type of the items that this Observable emits
      Parameters:
      key - the key value
      f - a function that accepts an Subscriber<T>, and invokes its onNext, onError, and onCompleted methods as appropriate
      Returns:
      a GroupedObservable that, when a Subscriber subscribes to it, will execute the specified function
    • getKey

      public K getKey()
      Returns the key that identifies the group of items emitted by this GroupedObservable
      Returns:
      the key that the items emitted by this GroupedObservable were grouped by