diff --git a/rxjava-core/src/main/java/rx/Observable.java b/rxjava-core/src/main/java/rx/Observable.java index 4b80d4e049..56a4664654 100644 --- a/rxjava-core/src/main/java/rx/Observable.java +++ b/rxjava-core/src/main/java/rx/Observable.java @@ -303,6 +303,33 @@ private Subscription protectivelyWrapAndSubscribe(Observer o) { return subscription.wrap(subscribe(new SafeObserver(subscription, o))); } + /** + * Subscribe and ignore all events. + * + * @return + */ + public Subscription subscribe() { + return protectivelyWrapAndSubscribe(new Observer() { + + @Override + public void onCompleted() { + // do nothing + } + + @Override + public void onError(Throwable e) { + handleError(e); + throw new OnErrorNotImplementedException(e); + } + + @Override + public void onNext(T args) { + // do nothing + } + + }); + } + /** * An {@link Observer} must call an Observable's {@code subscribe} method * in order to receive items and notifications from the Observable.