Skip to content

Commit 18ea25a

Browse files
committed
javadoc improvements:
* diagrams for skip(t), single(), take(t), skipLast(t) * minor corrections, reformatting of javadoc comments
1 parent d39d9cf commit 18ea25a

File tree

1 file changed

+81
-53
lines changed

1 file changed

+81
-53
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 81 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ public void onNext(T args) {
352352
*
353353
* @param onNext
354354
* @return
355+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable#onnext-oncompleted-and-onerror">RxJava Wiki: onNext, onCompleted, and onError</a>
355356
*/
356357
public Subscription subscribe(final Action1<? super T> onNext) {
357358
if (onNext == null) {
@@ -391,6 +392,7 @@ public void onNext(T args) {
391392
* @param onNext
392393
* @param scheduler
393394
* @return
395+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable#onnext-oncompleted-and-onerror">RxJava Wiki: onNext, onCompleted, and onError</a>
394396
*/
395397
public Subscription subscribe(final Action1<? super T> onNext, Scheduler scheduler) {
396398
return subscribeOn(scheduler).subscribe(onNext);
@@ -403,6 +405,7 @@ public Subscription subscribe(final Action1<? super T> onNext, Scheduler schedul
403405
* @param onNext
404406
* @param onError
405407
* @return
408+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable#onnext-oncompleted-and-onerror">RxJava Wiki: onNext, onCompleted, and onError</a>
406409
*/
407410
public Subscription subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError) {
408411
if (onNext == null) {
@@ -447,6 +450,7 @@ public void onNext(T args) {
447450
* @param onError
448451
* @param scheduler
449452
* @return
453+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable#onnext-oncompleted-and-onerror">RxJava Wiki: onNext, onCompleted, and onError</a>
450454
*/
451455
public Subscription subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError, Scheduler scheduler) {
452456
return subscribeOn(scheduler).subscribe(onNext, onError);
@@ -460,6 +464,7 @@ public Subscription subscribe(final Action1<? super T> onNext, final Action1<Thr
460464
* @param onError
461465
* @param onComplete
462466
* @return
467+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable#onnext-oncompleted-and-onerror">RxJava Wiki: onNext, onCompleted, and onError</a>
463468
*/
464469
public Subscription subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError, final Action0 onComplete) {
465470
if (onNext == null) {
@@ -507,6 +512,7 @@ public void onNext(T args) {
507512
* @param onComplete
508513
* @param scheduler
509514
* @return
515+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable#onnext-oncompleted-and-onerror">RxJava Wiki: onNext, onCompleted, and onError</a>
510516
*/
511517
public Subscription subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError, final Action0 onComplete, Scheduler scheduler) {
512518
return subscribeOn(scheduler).subscribe(onNext, onError, onComplete);
@@ -519,7 +525,7 @@ public Subscription subscribe(final Action1<? super T> onNext, final Action1<Thr
519525
public Observable<T> asObservable() {
520526
return create(new OperationAsObservable<T>(this));
521527
}
522-
528+
523529
/**
524530
* Returns a {@link ConnectableObservable} that upon connection causes the
525531
* source Observable to push results into the specified subject.
@@ -641,6 +647,7 @@ public Subscription onSubscribe(Observer<? super T> observer) {
641647
* @return an Observable that, when an {@link Observer} subscribes to it,
642648
* will execute the given function
643649
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#create">RxJava Wiki: create()</a>
650+
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.create.aspx">MSDN: Observable.Create</a>
644651
*/
645652
public static <T> Observable<T> create(OnSubscribeFunc<T> func) {
646653
return new Observable<T>(func);
@@ -1074,7 +1081,7 @@ public static <T> Observable<T> from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T
10741081
* @param count the number of sequential Integers to generate
10751082
* @return an Observable that emits a range of sequential Integers
10761083
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#range">RxJava Wiki: range()</a>
1077-
* @see MSDN: <a href="http://msdn.microsoft.com/en-us/library/hh229460.aspx">Observable.Range Method (Int32, Int32)</a>
1084+
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229460.aspx">MSDN: Observable.Range</a>
10781085
*/
10791086
public static Observable<Integer> range(int start, int count) {
10801087
return from(Range.createWithCount(start, count));
@@ -1091,7 +1098,7 @@ public static Observable<Integer> range(int start, int count) {
10911098
* @param scheduler the scheduler to run the generator loop on
10921099
* @return an Observable that emits a range of sequential Integers
10931100
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#range">RxJava Wiki: range()</a>
1094-
* @see MSDN: <a href="http://msdn.microsoft.com/en-us/library/hh211896.aspx">Observable.Range Method (Int32, Int32, IScheduler)</a>
1101+
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211896.aspx">MSDN: Observable.Range</a>
10951102
*/
10961103
public static Observable<Integer> range(int start, int count, Scheduler scheduler) {
10971104
return from(Range.createWithCount(start, count), scheduler);
@@ -5382,29 +5389,30 @@ public Observable<T> skip(int num) {
53825389

53835390
/**
53845391
* Create an Observable that skips values before the given time ellapses.
5392+
* <p>
5393+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/skip.t.png">
53855394
*
5386-
* @param time
5387-
* the length of the time window
5388-
* @param unit
5389-
* the time unit
5395+
* @param time the length of the time window
5396+
* @param unit the time unit
53905397
* @return an Observable that skips values before the given time ellapses
5398+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Filtering-Observables#skip">RxJava Wiki: skip()</a>
53915399
*/
53925400
public Observable<T> skip(long time, TimeUnit unit) {
53935401
return skip(time, unit, Schedulers.threadPoolForComputation());
53945402
}
53955403

53965404
/**
5397-
* Create an Observable that skips values before the given time
5398-
* elapses while waiting on the given scheduler.
5405+
* Create an Observable that skips values before the given time elapses
5406+
* while waiting on the given scheduler.
5407+
* <p>
5408+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/skip.ts.png">
53995409
*
5400-
* @param time
5401-
* the length of the time window
5402-
* @param unit
5403-
* the time unit
5404-
* @param scheduler
5405-
* the scheduler where the timed wait happens
5406-
* @return an Observable that skips values before the given time
5407-
* elapses while waiting on the given scheduler
5410+
* @param time the length of the time window
5411+
* @param unit the time unit
5412+
* @param scheduler the scheduler where the timed wait happens
5413+
* @return an Observable that skips values before the given time elapses
5414+
* while waiting on the given scheduler
5415+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Filtering-Observables#skip">RxJava Wiki: skip()</a>
54085416
*/
54095417
public Observable<T> skip(long time, TimeUnit unit, Scheduler scheduler) {
54105418
return create(new OperationSkip.SkipTimed<T>(this, time, unit, scheduler));
@@ -5414,12 +5422,13 @@ public Observable<T> skip(long time, TimeUnit unit, Scheduler scheduler) {
54145422
* If the Observable completes after emitting a single item, return an
54155423
* Observable containing that item. If it emits more than one item or no
54165424
* item, throw an IllegalArgumentException.
5425+
* <p>
5426+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/single.png">
54175427
*
54185428
* @return an Observable that emits the single item emitted by the source
54195429
* Observable that matches the predicate
5420-
* @throws IllegalArgumentException
5421-
* if the source emits more than one item
5422-
* or no items
5430+
* @throws IllegalArgumentException if the source emits more than one item
5431+
* or no items
54235432
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#single-and-singleordefault">RxJava Wiki: single()</a>
54245433
* @see MSDN: <code>Observable.singleAsync()</code>
54255434
*/
@@ -5605,29 +5614,38 @@ public Observable<T> take(final int num) {
56055614
}
56065615

56075616
/**
5608-
* Create an Observable that takes the emitted values of the source
5609-
* Observable before the time runs out.
5610-
* @param time the length of the time window
5611-
* @param unit the time unit
5612-
* @return an Observable that takes the emitted values of the source
5613-
* Observable before the time runs out.
5614-
*/
5615-
public Observable<T> take(long time, TimeUnit unit) {
5616-
return take(time, unit, Schedulers.threadPoolForComputation());
5617-
}
5617+
* Create an Observable that emits the emitted items from the source
5618+
* Observable before the time runs out.
5619+
* <p>
5620+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/take.t.png">
5621+
*
5622+
* @param time the length of the time window
5623+
* @param unit the time unit
5624+
* @return an Observable that emits the emitted items from the source
5625+
* Observable before the time runs out
5626+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Filtering-Observables#take">RxJava Wiki: take()</a>
5627+
*/
5628+
public Observable<T> take(long time, TimeUnit unit) {
5629+
return take(time, unit, Schedulers.threadPoolForComputation());
5630+
}
56185631

5619-
/**
5620-
* Create an Observable that takes the emitted values of the source
5621-
* Observable before the time runs out, waiting on the given scheduler.
5622-
* @param time the length of the time window
5623-
* @param unit the time unit
5624-
* @param scheduler the scheduler used for time source
5625-
* @return an Observable that takes the emitted values of the source
5626-
* Observable before the time runs out, waiting on the given scheduler.
5627-
*/
5628-
public Observable<T> take(long time, TimeUnit unit, Scheduler scheduler) {
5629-
return create(new OperationTake.TakeTimed<T>(this, time, unit, scheduler));
5630-
}
5632+
/**
5633+
* Create an Observable that emits the emitted items from the source
5634+
* Observable before the time runs out, waiting on the given scheduler.
5635+
* <p>
5636+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/take.ts.png">
5637+
*
5638+
* @param time the length of the time window
5639+
* @param unit the time unit
5640+
* @param scheduler the scheduler used for time source
5641+
* @return an Observable that emits the emitted items from the source
5642+
* Observable before the time runs out, waiting on the given
5643+
* scheduler
5644+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Filtering-Observables#take">RxJava Wiki: take()</a>
5645+
*/
5646+
public Observable<T> take(long time, TimeUnit unit, Scheduler scheduler) {
5647+
return create(new OperationTake.TakeTimed<T>(this, time, unit, scheduler));
5648+
}
56315649

56325650
/**
56335651
* Returns an Observable that emits items emitted by the source Observable
@@ -5972,25 +5990,35 @@ public Observable<T> skipLast(int count) {
59725990
}
59735991

59745992
/**
5975-
* Create an observable which skips values emitted in a time window
5976-
* before the source completes.
5993+
* Create an Observable that skips values emitted in a time window before
5994+
* the source completes.
5995+
* <p>
5996+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/skipLast.t.png">
5997+
*
59775998
* @param time the length of the time window
59785999
* @param unit the time unit
5979-
* @return an observable which skips values emitted in a time window
5980-
* before the source completes
6000+
* @return an Observable that skips values emitted in a time window before
6001+
* the source completes
6002+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Filtering-Observables#skiplast">RxJava Wiki: skipLast()</a>
6003+
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211750.aspx">MSDN: Observable.SkipLast</a>
59816004
*/
59826005
public Observable<T> skipLast(long time, TimeUnit unit) {
59836006
return skipLast(time, unit, Schedulers.threadPoolForComputation());
59846007
}
59856008

59866009
/**
5987-
* Create an observable which skips values emitted in a time window
5988-
* before the source completes by using the given scheduler as time source.
6010+
* Create an Observable that skips values emitted in a time window before
6011+
* the source completes by using the given scheduler as time source.
6012+
* <p>
6013+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/skipLast.ts.png">
6014+
*
59896015
* @param time the length of the time window
59906016
* @param unit the time unit
59916017
* @param scheduler the scheduler used for time source
5992-
* @return an observable which skips values emitted in a time window
5993-
* before the source completes by using the given scheduler as time source
6018+
* @return an Observable that skips values emitted in a time window before
6019+
* the source completes by using the given scheduler as time source
6020+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Filtering-Observables#skiplast">RxJava Wiki: skipLast()</a>
6021+
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211750.aspx">MSDN: Observable.SkipLast</a>
59946022
*/
59956023
public Observable<T> skipLast(long time, TimeUnit unit, Scheduler scheduler) {
59966024
return create(new OperationSkipLast.SkipLastTimed<T>(this, time, unit, scheduler));
@@ -6894,8 +6922,8 @@ public void onNext(T args) { }
68946922
* <p>
68956923
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/doOnNext.png">
68966924
*
6897-
* @param onCompleted the action to invoke when the source Observable calls
6898-
* <code>onCompleted</code>
6925+
* @param onNext the action to invoke when the source Observable calls
6926+
* <code>onNext</code>
68996927
* @return the source Observable with the side-effecting behavior applied
69006928
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#dooneach">RxJava Wiki: doOnNext()</a>
69016929
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229804.aspx">MSDN: Observable.Do</a>
@@ -6958,7 +6986,7 @@ public void onNext(T v) {
69586986
* For why this is being used see
69596987
* https://github.com/Netflix/RxJava/issues/216 for discussion on
69606988
* "Guideline 6.4: Protect calls to user code from within an operator"
6961-
*
6989+
* <p>
69626990
* Note: If strong reasons for not depending on package names comes up then
69636991
* the implementation of this method can change to looking for a marker
69646992
* interface.

0 commit comments

Comments
 (0)