
educationDec 31, 201815:22pending
147: Disposing RxJava 2 Streams with AutoDispose
About this episode
In this short fragment episode, Donn explains how you can clean up your RxJava 2 streams and ensure no memory leaks are occurring by using the AutoDispose library from Uber.
Shownotes
Code Samples
Java
myObservable
.map(...)
.as(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(this)))
.subscribe(...)
Kotlin
myObservable
.map(...)
.autoDisposable(AndroidLifcycleScopeProvider.from(this))
.subscribe(...)
With Scope Event Provided
myObservable
.map(...)
.autoDisposable(AndroidLifcycleScopeProvider.from(this, Lifecycle.Event.ON_DESTROY))
.subscribe(...)
Testing
// File: CustomerService.kt
class CustomerService @Inject constructor(...) {
lateinit var scopeProvider: ScopeProvider
}
// Usage in Fragment/Activity/etc
val service = CustomerService(...).apply {
scopeProvider = AndroidLifecycleScopeProvider.from(this)
}
// Usage in Test
val service = CustomerService(...).apply {
scopeProvider = TestScopeProvider.create()
}
Contact
- @fragmentedcast or our Youtube channel
- @donnfelker and donnfelker (on Instagram)
- @kaushikgopal and kaushikgopal (on Instagram)
- Fragmented Chat
Get every episode summarized
Each time Fragmented - AI Developer Podcast publishes, we email you a written briefing from the transcript — the topics, who appeared, and any specific claims, with the ad reads skipped.
Email me new episodesFree for 3 shows. No card needed.
Hosts & guests
No transcript yet
This episode has not been transcribed. Request it and it moves to the front of the queue.
More episodes
More from Fragmented - AI Developer Podcast

311 - Self learning harnesses are here
Fragmented - AI Developer Podcast
Sep 6, 202612:41completed

310 - Mitchell Hashimoto on Ghostty & His Agentic Coding Workflow
Fragmented - AI Developer Podcast
Apr 14, 202659:43failed

309 - Background Agents
Fragmented - AI Developer Podcast
Apr 1, 202625:37failed

308 - How Image Diffusion Models Work - the 20 minute explainer
Fragmented - AI Developer Podcast
Mar 24, 202624:44failed