Class BufferUntilSubscriber<T>

  • Type Parameters:
    T - the type of the items to be buffered
    All Implemented Interfaces:
    Observer<T>

    public final class BufferUntilSubscriber<T>
    extends Subject<T,​T>
    A solution to the "time gap" problem that occurs with groupBy and pivot.

    This currently has temporary unbounded buffers. It needs to become bounded and then do one of two things:

    1. blow up and make the user do something about it
    2. work with the backpressure solution ... still to be implemented (such as co-routines)

    Generally the buffer should be very short lived (milliseconds) and then stops being involved. It can become a memory leak though if a GroupedObservable backed by this class is emitted but never subscribed to (such as filtered out). In that case, either a time-bomb to throw away the buffer, or just blowing up and making the user do something about it is needed.

    For example, to filter out GroupedObservables, perhaps they need a silent subscribe() on them to just blackhole the data.

    This is an initial start at solving this problem and solves the immediate problem of groupBy and pivot and trades off the possibility of memory leak for deterministic functionality.

    See Also:
    the Github issue describing the time gap problem
    • Method Detail

      • create

        public static <T> BufferUntilSubscriber<T> create()
        Creates a default, unbounded buffering Subject instance.
        Type Parameters:
        T - the value type
        Returns:
        the instance
      • emit

        private void emit​(java.lang.Object v)
      • onError

        public void onError​(java.lang.Throwable e)
        Description copied from interface: Observer
        Notifies the Observer that the Observable has experienced an error condition.

        If the Observable calls this method, it will not thereafter call Observer.onNext(T) or Observer.onCompleted().

        Parameters:
        e - the exception encountered by the Observable
      • hasObservers

        public boolean hasObservers()
        Description copied from class: Subject
        Indicates whether the Subject has Observers subscribed to it.
        Specified by:
        hasObservers in class Subject<T,​T>
        Returns:
        true if there is at least one Observer subscribed to this Subject, false otherwise