Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disposing on Android 1
class MyActivity {
var fetchDataDisposable: Disposable? = null
/* ... */
fun onCreate() {
super.onCreate()
/* stuff */
fetchDataDisposable = fetchData()
.flatMap(::prepareData)
.subscribe(::displayData)
}
fun onDestroy() {
fetchDataDisposable?.dispose()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment