Created
August 11, 2019 08:11
-
-
Save drawers/a2d141e90428251eaaf8baab520dc551 to your computer and use it in GitHub Desktop.
Cleaning it up slightly
This file contains 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
private typealias PageDebounceSelector = (data: PickupData) -> ObservableSource<Long> | |
class PickupFragment { | |
override fun onStart() { | |
super.onStart() | |
source().viewStates() | |
.debounce(loadingOnly) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe { data: PickupData -> | |
adapter.setData(data) | |
} | |
.addTo(disposables) | |
} | |
private val loadingOnly: PageDebounceSelector = | |
{ | |
when { | |
it.isLoading() -> Observable.timer(250, TimeUnit.MILLISECONDS) | |
else -> Observable.empty() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment