Skip to content

Commit 7ef16c9

Browse files
committed
Implemented the scheduler version of the 'Return' operator
1 parent 767557d commit 7ef16c9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,31 @@ public static <T> Observable<T> just(T value) {
10121012
return from(list);
10131013
}
10141014

1015+
/**
1016+
* Returns an Observable that emits a single item and then completes in a specified scheduler.
1017+
* <p>
1018+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/just.png">
1019+
* <p>
1020+
* To convert any object into an Observable that emits that object, pass that object into the
1021+
* <code>just</code> method.
1022+
* <p>
1023+
* This is similar to the {@link #from(java.lang.Object[])} method, except that
1024+
* <code>from()</code> will convert an {@link Iterable} object into an Observable that emits
1025+
* each of the items in the Iterable, one at a time, while the <code>just()</code> method
1026+
* converts an Iterable into an Observable that emits the entire Iterable as a single item.
1027+
*
1028+
* @param value
1029+
* the item to pass to the {@link Observer}'s {@link Observer#onNext onNext} method
1030+
* @param scheduler
1031+
* the scheduler to send the single element on
1032+
* @param <T>
1033+
* the type of that item
1034+
* @return an Observable that emits a single item and then completes
1035+
*/
1036+
public static <T> Observable<T> just(T value, Scheduler scheduler) {
1037+
return just(value).observeOn(scheduler);
1038+
}
1039+
10151040
/**
10161041
* Flattens a sequence of Observables emitted by an Observable into one Observable, without any
10171042
* transformation.

0 commit comments

Comments
 (0)