KO
|
EN
gitlite — search
Search
#python
#java
#python3
#arduino
#golang
#machine-learning
#rust
#html
#flask
#javascript
#seismology
#nodejs
rx-ktx
★ 12
Open GitHub ↗
No description available.
Download README (.md)
Explore Similar Repositories
ent
:
An entity layer for Prisma 1 that uses the DataMapper pattern.
fivem-panel
:
Panel de administración
iframeBusterXSS
:
Check for know iframeBuster XSS
fine-Grained-classify
:
fine-Grained classify 细颗粒度图像分类
nextjs-express-typescript
:
Minimal starter project
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
rx-ktx
?
Download (.md)
ReactiveX Kotlin Extensions ============ Kotlin extensions for convenient usage of Rx library. Download -------- [  ](https://bintray.com/idapgroup/kotlin/rx-ktx/1.0.0/link) Add repository to your root `build.gradle` ```groovy repositories { jcenter() } ``` ```groovy dependencies { implementation 'com.idapgroup:rx-ktx:latest-version' } ``` Extensions ------------- Each Rx type(Observable, Single, Completable, Maybe, Flowable) has these extensions: * Subscribe On: * **subscribeIo()** -> subscribeOn(Schedulers.io()) * **subscribeComputation()** -> subscribeOn(Schedulers.computation()) * **subscribeMainThread()** -> subscribeOn(AndroidSchedulers.mainThread()) * Observe On: * **io()** -> observeOn(Schedulers.io()) * **computation()** -> observeOn(Schedulers.computation()) * **mainThread()** -> observeOn(AndroidSchedulers.mainThread()) * Logging all rx events (such as onSubscribe, onError etc.) for debug mode based on [Timber][1] logs: ```kotlin Observable.just(1) .debug() .subscribe() ``` Logs: ~~~ .onSubscribe() thread: main [1]-> value: 1, passed time: 3 ms, thread: main .onComplete() passed time: 5 ms, thread: main ~~~ Each OnNext() event has counter that helps to track execution steps. ~~~ [1]-> ... [2]-> ... [3]-> ... ... ~~~ * disposeOn(LifecycleOwner, Lifecycle.Event) method that helps auto control of your disposable by LifecycleOwner lifecycle. ```kotlin class ExampleActivity: AppCompatActivity() { fun doWork() { someBigWork() .subscribe() .disposeOn(this, Lifecycle.Event.ON_DESTROY) } } ``` For more convenience added all lifecycle events methods: ~~~ disposeOnPause(LifecycleOwner) disposeOnStop(LifecycleOwner) disposeOnDestroy(LifecycleOwner) ~~~ * Top level functions for converting com.google.android.gms.tasks.Task to rx type: ```kotlin completableOf { task() } singleOf { task() } maybeOf { task() } ``` AutoDisposable ------------ Interface that helps dispose/cancel your Disposable by events that you define. Already implemented fo ViewModel ```kotlin open class RxViewModel : ViewModel(), AutoDisposable by AutoDisposableImpl() { override fun onCleared() { dispose() super.onCleared() } } ``` Using example: ```kotlin class TestRxViewModel : RxViewModel() { val testDisposable = Observable.never<Int>() .subscribe() .autoDispose() } ``` [1]: https://raw.githubusercontent.com/JakeWharton/timber/