Skip to content

Commit b8ae284

Browse files
Merge pull request ReactiveX#415 from zsxwing/empty-with-scheduler
Implemented the 'Empty' operator with scheduler
2 parents da429ea + d7a45d4 commit b8ae284

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,30 @@ public static <T> Observable<T> create(OnSubscribeFunc<T> func) {
544544
* the type of the items (ostensibly) emitted by the Observable
545545
* @return an Observable that returns no data to the {@link Observer} and immediately invokes
546546
* the {@link Observer}'s {@link Observer#onCompleted() onCompleted} method
547+
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229670(v=vs.103).aspx">MSDN: Observable.Empty Method</a>
547548
*/
548549
public static <T> Observable<T> empty() {
549550
return from(new ArrayList<T>());
550551
}
551552

553+
/**
554+
* Returns an Observable that emits no data to the {@link Observer} and immediately invokes
555+
* its {@link Observer#onCompleted onCompleted} method with the specified scheduler.
556+
* <p>
557+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/empty.png">
558+
* @param scheduler
559+
* the scheduler to call the {@link Observer#onCompleted onCompleted} method.
560+
* @param <T>
561+
* the type of the items (ostensibly) emitted by the Observable
562+
* @return an Observable that returns no data to the {@link Observer} and immediately invokes
563+
* the {@link Observer}'s {@link Observer#onCompleted() onCompleted} method with
564+
* the specified scheduler.
565+
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229066(v=vs.103).aspx">MSDN: Observable.Empty Method (IScheduler)</a>
566+
*/
567+
public static <T> Observable<T> empty(Scheduler scheduler) {
568+
return Observable.<T>empty().subscribeOn(scheduler);
569+
}
570+
552571
/**
553572
* Returns an Observable that invokes an {@link Observer}'s {@link Observer#onError onError} method when the Observer subscribes to it
554573
* <p>

0 commit comments

Comments
 (0)