RxJava



rx.subjects
Class PublishSubject<T>

java.lang.Object
  extended by rx.Observable<R>
      extended by rx.subjects.Subject<T,T>
          extended by rx.subjects.PublishSubject<T>
Type Parameters:
T -
All Implemented Interfaces:
Observer<T>

public class PublishSubject<T>
extends Subject<T,T>

Subject that, once and Observer has subscribed, publishes all subsequent events to the subscriber.

Example usage:

 ublishSubject<Object> subject = PublishSubject.create();
  // observer1 will receive all onNext and onCompleted events
  subject.subscribe(observer1);
  subject.onNext("one");
  subject.onNext("two");
  // observer2 will only receive "three" and onCompleted
  subject.subscribe(observer2);
  subject.onNext("three");
  subject.onCompleted();

   


Nested Class Summary
 
Nested classes/interfaces inherited from class rx.Observable
Observable.OnSubscribeFunc<T>
 
Constructor Summary
protected PublishSubject(Observable.OnSubscribeFunc<T> onSubscribe, java.util.concurrent.ConcurrentHashMap<Subscription,Observer<? super T>> observers)
           
 
Method Summary
static
<T> PublishSubject<T>
create()
           
 void onCompleted()
          Notifies the Observer that the Observable has finished sending push-based notifications.
 void onError(java.lang.Throwable e)
          Notifies the Observer that the Observable has experienced an error condition.
 void onNext(T args)
          Provides the Observer with new data.
 
Methods inherited from class rx.Observable
aggregate, aggregate, all, amb, amb, amb, amb, amb, amb, amb, amb, amb, average, averageDoubles, averageFloats, averageLongs, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, cache, cast, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, concat, concat, concat, concat, concat, concat, concat, concat, concat, contains, count, create, debounce, debounce, defaultIfEmpty, defer, dematerialize, distinct, distinct, distinctUntilChanged, distinctUntilChanged, doOnCompleted, doOnEach, doOnEach, doOnEach, doOnEach, doOnError, elementAt, elementAtOrDefault, empty, empty, error, error, exists, filter, finallyDo, first, first, firstOrDefault, firstOrDefault, flatMap, from, from, from, from, from, from, from, from, from, from, from, from, from, from, from, groupBy, groupBy, ignoreElements, interval, interval, isEmpty, just, just, last, map, mapMany, mapWithIndex, materialize, max, max, maxBy, maxBy, merge, merge, merge, merge, merge, merge, merge, merge, merge, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, min, min, minBy, minBy, multicast, never, observeOn, ofType, onErrorResumeNext, onErrorResumeNext, onErrorReturn, onExceptionResumeNext, parallel, parallel, publish, publishLast, range, reduce, reduce, replay, retry, retry, sample, sample, scan, scan, sequenceEqual, sequenceEqual, skip, skipLast, skipWhile, skipWhileWithIndex, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, sum, sumDoubles, sumFloats, sumLongs, switchDo, switchOnNext, synchronize, synchronize, synchronize, take, takeFirst, takeFirst, takeLast, takeUntil, takeWhile, takeWhileWithIndex, throttleFirst, throttleFirst, throttleLast, throttleLast, throttleWithTimeout, throttleWithTimeout, timeInterval, timeInterval, timeout, timeout, timeout, timeout, timestamp, toBlockingObservable, toList, toSortedList, toSortedList, using, where, window, window, window, window, window, window, window, window, window, window, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PublishSubject

protected PublishSubject(Observable.OnSubscribeFunc<T> onSubscribe,
                         java.util.concurrent.ConcurrentHashMap<Subscription,Observer<? super T>> observers)
Method Detail

create

public static <T> PublishSubject<T> create()

onCompleted

public void onCompleted()
Description copied from interface: Observer
Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this closure if it calls onError.


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 closure, it will not thereafter call onNext or onCompleted.


onNext

public void onNext(T args)
Description copied from interface: Observer
Provides the Observer with new data.

The Observable calls this closure 1 or more times, unless it calls onError in which case this closure may never be called.

The Observable will not call this closure again after it calls either onCompleted or onError.