Skip to content

Commit 0c19e4e

Browse files
committed
Diagrams and some new docs for Observable subclasses
Some marble or marblish diagrams and a bit of new documentation for the BlockingObservable and ConnectableObservable subclasses.
1 parent ed16276 commit 0c19e4e

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

rxjava-core/src/main/java/rx/observables/BlockingObservable.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
* Extension of {@link Observable} that provides blocking operators.
3333
* <p>
3434
* Constructud via {@link #from(Observable)} or {@link Observable#toBlockingObservable()}
35+
* <p>
36+
* The documentation for this interface makes use of a form of marble diagram that has been
37+
* modified to illustrate blocking operators. The following legend explains marble diagrams:
38+
* <p>
39+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/legend.png">
40+
* <p>
41+
* For more information see the <a href="https://github.com/Netflix/RxJava/wiki/Observable">RxJava Wiki</a>
3542
*
3643
* @param <T>
3744
*/
@@ -49,6 +56,8 @@ public Subscription call(Observer<T> observer) {
4956

5057
/**
5158
* Returns an iterator that iterates all values of the observable.
59+
* <p>
60+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.toIterator.png">
5261
*
5362
* @param source
5463
* an observable sequence to get an iterator for.
@@ -62,6 +71,8 @@ public static <T> Iterator<T> toIterator(Observable<T> source) {
6271

6372
/**
6473
* Returns the last element of an observable sequence with a specified source.
74+
* <p>
75+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.last.png">
6576
*
6677
* @param source
6778
* the source Observable
@@ -156,6 +167,8 @@ public Boolean call(T args) {
156167

157168
/**
158169
* Samples the most recent value in an observable sequence.
170+
* <p>
171+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.mostRecent.png">
159172
*
160173
* @param source
161174
* the source observable sequence.
@@ -171,6 +184,8 @@ public static <T> Iterable<T> mostRecent(Observable<T> source, T initialValue) {
171184

172185
/**
173186
* Samples the next value (blocking without buffering) from in an observable sequence.
187+
* <p>
188+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.next.png">
174189
*
175190
* @param items
176191
* the source observable sequence.
@@ -203,6 +218,8 @@ private static <T> T _singleOrDefault(BlockingObservable<T> source, boolean hasD
203218

204219
/**
205220
* Returns the only element of an observable sequence and throws an exception if there is not exactly one element in the observable sequence.
221+
* <p>
222+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.single.png">
206223
*
207224
* @param source
208225
* the source Observable
@@ -302,6 +319,8 @@ public static <T> Future<T> toFuture(final Observable<T> source) {
302319

303320
/**
304321
* Converts an observable sequence to an Iterable.
322+
* <p>
323+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.toIterable.png">
305324
*
306325
* @param source
307326
* the source Observable
@@ -331,6 +350,8 @@ private Subscription protectivelyWrapAndSubscribe(Observer<T> o) {
331350
* NOTE: This will block even if the Observable is asynchronous.
332351
* <p>
333352
* This is similar to {@link #subscribe(Observer)} but blocks. Because it blocks it does not need the {@link Observer#onCompleted()} or {@link Observer#onError(Exception)} methods.
353+
* <p>
354+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.forEach.png">
334355
*
335356
* @param onNext
336357
* {@link Action1}
@@ -395,6 +416,8 @@ public void onNext(T args) {
395416
* NOTE: This will block even if the Observable is asynchronous.
396417
* <p>
397418
* This is similar to {@link #subscribe(Observer)} but blocks. Because it blocks it does not need the {@link Observer#onCompleted()} or {@link Observer#onError(Exception)} methods.
419+
* <p>
420+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.forEach.png">
398421
*
399422
* @param o
400423
* onNext {@link Action1 action}
@@ -426,6 +449,8 @@ public void call(Object args) {
426449

427450
/**
428451
* Returns an iterator that iterates all values of the observable.
452+
* <p>
453+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.getIterator.png">
429454
*
430455
* @return the iterator that could be used to iterate over the elements of the observable.
431456
*/
@@ -435,6 +460,8 @@ public Iterator<T> getIterator() {
435460

436461
/**
437462
* Returns the last element of an observable sequence with a specified source.
463+
* <p>
464+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.last.png">
438465
*
439466
* @return the last element in the observable sequence.
440467
*/
@@ -527,6 +554,8 @@ public T lastOrDefault(T defaultValue, Object predicate) {
527554

528555
/**
529556
* Samples the most recent value in an observable sequence.
557+
* <p>
558+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.mostRecent.png">
530559
*
531560
* @param initialValue
532561
* the initial value that will be yielded by the enumerable sequence if no element has been sampled yet.
@@ -538,6 +567,8 @@ public Iterable<T> mostRecent(T initialValue) {
538567

539568
/**
540569
* Samples the next value (blocking without buffering) from in an observable sequence.
570+
* <p>
571+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.next.png">
541572
*
542573
* @return iterable that blocks upon each iteration until the next element in the observable source sequence becomes available.
543574
*/
@@ -547,6 +578,8 @@ public Iterable<T> next() {
547578

548579
/**
549580
* Returns the only element of an observable sequence and throws an exception if there is not exactly one element in the observable sequence.
581+
* <p>
582+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.single.png">
550583
*
551584
* @return The single element in the observable sequence.
552585
*/
@@ -642,6 +675,8 @@ public Future<T> toFuture() {
642675

643676
/**
644677
* Converts an observable sequence to an Iterable.
678+
* <p>
679+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.toIterable.png">
645680
*
646681
* @return Observable converted to Iterable.
647682
*/

rxjava-core/src/main/java/rx/observables/ConnectableObservable.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,29 @@
2020
import rx.Subscription;
2121
import rx.util.functions.Func1;
2222

23+
/**
24+
* A Connectable Observable resembles an ordinary Observable, except that it does not begin
25+
* emitting a sequence of values when it is subscribed to, but only when its connect() method is
26+
* called. In this way you can wait for all intended observers to subscribe to the Observable
27+
* before the Observable begins emitting values.
28+
* <p>
29+
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/publishConnect.png">
30+
* <p>
31+
* For more information see the <a href="https://github.com/Netflix/RxJava/wiki/Observable">RxJava Wiki</a>
32+
*
33+
* @param <T>
34+
*/
35+
2336
public abstract class ConnectableObservable<T> extends Observable<T> {
2437

2538
protected ConnectableObservable(Func1<Observer<T>, Subscription> onSubscribe) {
2639
super(onSubscribe);
2740
}
2841

42+
/**
43+
* Call a Connectable Observable's connect() method to instruct it to begin emitting the
44+
* objects from its underlying Observable to its subscribing observers.
45+
*/
2946
public abstract Subscription connect();
3047

3148
}

0 commit comments

Comments
 (0)