# RxJava 1 -\> RxJava 2 (Disposing Subscriptions)

DevFeed: [RxJava 1 -\> RxJava 2 (Disposing Subscriptions)](<https://devfeed.tech/articles/rxjava-1-rxjava-2-disposing-subscriptions-25322.md>)

Original publisher: [Read original article](<https://kau.sh/blog/rxjava-1-rxjava-2-disposing-subscriptions/>)

Author: Kaushik Gopal

Published: 2017-06-21T07:00:00Z

Content type: tutorial

Language: en

Sources: [Kaushik Gopal's Site](<https://devfeed.tech/sources/kaushik-gopal-s-site.md>)

Topics: [RxJava](<https://devfeed.tech/topics/rxjava.md>), [reactive](<https://devfeed.tech/topics/reactive.md>), [Streams](<https://devfeed.tech/topics/streams.md>)

Tags: [androiddev](<https://devfeed.tech/tags/androiddev.md>), [callback](<https://devfeed.tech/tags/callback.md>), [memory-leak](<https://devfeed.tech/tags/memory-leak.md>), [reactive-streams](<https://devfeed.tech/tags/reactive-streams.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>), [subscriber](<https://devfeed.tech/tags/subscriber.md>), [subscription](<https://devfeed.tech/tags/subscription.md>), [subscriptions](<https://devfeed.tech/tags/subscriptions.md>)

## AI overview

This continuation post explains how subscription disposal changed from RxJava 1.x to RxJava 2. In RxJava 2, Reactive Streams interfaces and subscriber callbacks provide access to subscriptions for cancellation and lifecycle management, rather than returning a subscription from subscribe methods.

## Source excerpt

2 part series This is a continuation post in a 2 part series: Understanding the changes Disposing subscriptions Disposing Subscriptions # This was the part that I initially found most tricky to grasp but also most important to know as an AndroidDev (memory leak and all). Jedi master Karnok explains this best in the wiki: In RxJava 1.x, the interface rx.Subscription was responsible for stream and resource lifecycle management, namely unsubscribing a sequence and releasing general resources such as scheduled tasks. The Reactive-Streams specification took this name for specifying an interaction point between a source and a consumer: org.reactivestreams.Subscription allows requesting a positive amount from the upstream and allows cancelling the sequence. From that definition alone, it would appear like nothing's changed but that is definitely not the case. In my first post, I pointed out: Publisher.subscribe(Subscriber) => Subscription The use of => vs = was intentional. If you look at the source code for Publisher's subscribe method again, you'll notice a return type of void viz. it doesn't return a Subscription for you to tack on to a CompositeSubscription (which you can then conveniently dispose of onStop/onDestroy). interface Publisher<T> { // return type void (not Subscription like before) void subscribe(Subscriber<? super T> s); } Karnok again: Because Reactive-Streams base interface, org.reactivestreams.Publisher defines the subscribe() method as void, Flowable.subscribe(Subscriber) no longer returns any Subscription (or Disposable). The other base reactive types also follow this signature with their respective subscriber types. So if you look at the declarations again // RxJava specific constructs // Observable implements "ObservableSource" interface ObservableSource<T> { void subscribe(Observer<? super T> observer); } // Single implements SingleSource interface SingleSource<T> { void subscribe(SingleObserver<? super T> observer); } interface CompletableSource {