Last active
October 1, 2018 06:36
-
-
Save sellmair/c6c980a7d67992e5dc74f807995e5837 to your computer and use it in GitHub Desktop.
Disposing on Android 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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