Skip to content

Commit 8e0c8c0

Browse files
committed
Implemented the 'Empty' operator with scheduler
1 parent a317533 commit 8e0c8c0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,23 @@ public static <T> Observable<T> empty() {
547547
return from(new ArrayList<T>());
548548
}
549549

550+
/**
551+
* Returns an Observable that emits no data to the {@link Observer} and immediately invokes
552+
* its {@link Observer#onCompleted onCompleted} method with the specified scheduler.
553+
* <p>
554+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/empty.png">
555+
* @param scheduler
556+
* the scheduler to call the {@link Observer#onCompleted onCompleted} method.
557+
* @param <T>
558+
* the type of the items (ostensibly) emitted by the Observable
559+
* @return an Observable that returns no data to the {@link Observer} and immediately invokes
560+
* the {@link Observer}'s {@link Observer#onCompleted() onCompleted} method with
561+
* the specified scheduler.
562+
*/
563+
public static <T> Observable<T> empty(Scheduler scheduler) {
564+
return Observable.<T>empty().subscribeOn(scheduler);
565+
}
566+
550567
/**
551568
* Returns an Observable that invokes an {@link Observer}'s {@link Observer#onError onError} method when the Observer subscribes to it
552569
* <p>

0 commit comments

Comments
 (0)