Skip to content

Commit c2c3ff6

Browse files
Empty subscribe
1 parent ebd519c commit c2c3ff6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,33 @@ private Subscription protectivelyWrapAndSubscribe(Observer<? super T> o) {
303303
return subscription.wrap(subscribe(new SafeObserver<T>(subscription, o)));
304304
}
305305

306+
/**
307+
* Subscribe and ignore all events.
308+
*
309+
* @return
310+
*/
311+
public Subscription subscribe() {
312+
return protectivelyWrapAndSubscribe(new Observer<T>() {
313+
314+
@Override
315+
public void onCompleted() {
316+
// do nothing
317+
}
318+
319+
@Override
320+
public void onError(Throwable e) {
321+
handleError(e);
322+
throw new OnErrorNotImplementedException(e);
323+
}
324+
325+
@Override
326+
public void onNext(T args) {
327+
// do nothing
328+
}
329+
330+
});
331+
}
332+
306333
/**
307334
* An {@link Observer} must call an Observable's {@code subscribe} method
308335
* in order to receive items and notifications from the Observable.

0 commit comments

Comments
 (0)