Skip to content

Instantly share code, notes, and snippets.

@sellmair
Last active October 1, 2018 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sellmair/c6c980a7d67992e5dc74f807995e5837 to your computer and use it in GitHub Desktop.
Save sellmair/c6c980a7d67992e5dc74f807995e5837 to your computer and use it in GitHub Desktop.
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