Extension functions and delegates for RxJava
This app provides a few extension functions and delegates for RxJava in Kotlin
implementation 'com.jacquessmuts:rxhelpers:{version}'
Extension | Description | Example |
---|---|---|
.filterRapidClicks() | Throttles out events within 300ms | Example |
.subscribeAndLogE{} | Same as .subscribe{}, except it logs an error by default. | Example |
.computationThread() | Same as observeOn(Schedulers.computation()) | Example |
.uiThread() | Same as observeOn(AndroidSchedulers.mainThread()) | Example |
Delegate | Description | Example |
---|---|---|
LazyPublishSubject<> | Creates a lazy-loaded PublishSubject<> | Example |
You can set the default handling of some functions. Do it in the onCreate
of your application.
RxHelper.setDefaultErrorHandling { throwable ->
// Every time .subscribeAndLogE catches an error, this will run
Timber.e(throwable)
}
// events faster than 500ms will be filtered out by .filterRapidClick()
RxHelper.setMaximumClickRapidity(500)