Skip to content

Commit

Permalink
Implemented the 'Throw' operator with scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
zsxwing committed Oct 9, 2013
1 parent abc8bec commit 3a23a9b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions rxjava-core/src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,30 @@ public static <T> Observable<T> empty(Scheduler scheduler) {
* @param <T>
* the type of the items (ostensibly) emitted by the Observable
* @return an Observable that invokes the {@link Observer}'s {@link Observer#onError onError} method when the Observer subscribes to it
* @see <a href="http://msdn.microsoft.com/en-us/library/hh244299(v=vs.103).aspx">MSDN: Observable.Throw Method</a>
*/
public static <T> Observable<T> error(Throwable exception) {
return new ThrowObservable<T>(exception);
}

/**
* Returns an Observable that invokes an {@link Observer}'s {@link Observer#onError onError} method with the specified scheduler.
* <p>
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/error.png">
*
* @param exception
* the particular error to report
* @param scheduler
* the scheduler to call the {@link Observer#onError onError} method.
* @param <T>
* the type of the items (ostensibly) emitted by the Observable
* @return an Observable that invokes the {@link Observer}'s {@link Observer#onError onError} method with the specified scheduler.
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211711(v=vs.103).aspx">MSDN: Observable.Throw Method</a>
*/
public static <T> Observable<T> error(Throwable exception, Scheduler scheduler) {
return Observable.<T> error(exception).observeOn(scheduler);
}

/**
* Converts an {@link Iterable} sequence into an Observable.
* <p>
Expand Down

0 comments on commit 3a23a9b

Please sign in to comment.