in sample/src/main/kotlin/autodispose2/sample/KotlinFragment.kt [90:111]
override fun onResume() {
super.onResume()
Log.d(TAG, "onResume()")
// Using automatic disposal, this should determine that the correct time to
// dispose is onPause (the opposite of onResume).
Observable.interval(1, TimeUnit.SECONDS)
.doOnDispose { Log.i(TAG, "Disposing subscription from onResume()") }
.autoDispose(scopeProvider)
.subscribeBy { num -> Log.i(TAG, "Started in onResume(), running until in onPause(): $num") }
// Setting a specific untilEvent, this should dispose in onDestroy.
Observable.interval(1, TimeUnit.SECONDS)
.doOnDispose {
Log.i(TAG, "Disposing subscription from onResume() with untilEvent ON_DESTROY")
}
.autoDispose(AndroidLifecycleScopeProvider.from(this, Lifecycle.Event.ON_DESTROY))
.subscribeBy { num ->
Log.i(TAG, "Started in onResume(), running until in onDestroy(): $num")
}
}