Hint: Fire and Forget
You do not forget that you support the subscription. Just call a subscription and go.
service.doSomething() .timeout(10, TimeUnit.SECONDS) .subscribe( () -> { otherService.doAction() }
Edit : garbage collection.
If you are not doing something very strange (for example, using WeakReference), your doSomething prevent the entire chain from being collected.
Think of RxJava as a bow, every time you transform an observable (map, doOnNext, etc.), a new Observable is created that wraps the old observable like a bow.
For each conversion, a new Subscriber is created that passes callbacks (onNext, onCompleted, onError) to the next Subscriber in the chain.
The main reason for Subscription is that you can call unsubscribe . There are two reasons why you can unsubscribe.
You have a hot observable. Basically, this observable will radiate values ββforever. An example would be an observed value that emits a time every 30 seconds. You can call unsubscribe when you are no longer interested in the meaning of time.
You want to cancel a long operation. Suppose you are loading a web page to display to the user, if the user clicks back, you want to cancel the download (you no longer care about the results).
Example Source code for a card operation
The map simply calls lift with the OperatorMap argument. Lift creates a new Observable based on Operator , so far it can be ignored.
public final <R> Observable<R> map(Func1<? super T, ? extends R> func) { return lift(new OperatorMap<T, R>(func)); }
OperatorMap creates a new Subscriber that basically just transfers the calls to all the Subscriber that it defines. It can be a Subscriber that you pass to a subscribe or a Subscriber created by another map transformation, it doesn't really matter.
public final class OperatorMap<T, R> implements Operator<R, T> { private final Func1<? super T, ? extends R> transformer; public OperatorMap(Func1<? super T, ? extends R> transformer) { this.transformer = transformer; } @Override public Subscriber<? super T> call(final Subscriber<? super R> o) { return new Subscriber<T>(o) { @Override public void onCompleted() { o.onCompleted(); } @Override public void onError(Throwable e) { o.onError(e); } @Override public void onNext(T t) { try { o.onNext(transformer.call(t)); } catch (Throwable e) { Exceptions.throwOrReport(e, this, t); } } }; } }