File tree Expand file tree Collapse file tree 4 files changed +37
-5
lines changed
src/main/java/com/wolkowiczmateusz/androidextensions Expand file tree Collapse file tree 4 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -28,13 +28,22 @@ android {
2828
2929dependencies {
3030 implementation fileTree(dir : ' libs' , include : [' *.jar' ])
31-
31+ implementation " org.jetbrains.kotlin:kotlin-stdlib-jdk7: $k otlin_version "
3232 implementation ' androidx.appcompat:appcompat:1.0.2'
33+
34+ // Reactive extensions
35+ implementation " io.reactivex.rxjava2:rxjava:$rx_java "
36+ implementation " io.reactivex.rxjava2:rxandroid:$rx_java_android "
37+
38+ // KTX
39+ implementation " androidx.core:core-ktx:$android_core_ktx "
40+ implementation " androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_reactivestreams_ktx "
41+ implementation " androidx.collection:collection-ktx:$collection_ktx "
42+ implementation " androidx.fragment:fragment-ktx:$fragment_ktx "
43+
3344 testImplementation ' junit:junit:4.12'
3445 androidTestImplementation ' androidx.test:runner:1.2.0'
3546 androidTestImplementation ' androidx.test.espresso:espresso-core:3.2.0'
36- compile " androidx.core:core-ktx:+"
37- implementation " org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version "
3847}
3948repositories {
4049 mavenCentral()
Original file line number Diff line number Diff line change 1+ package com.wolkowiczmateusz.androidextensions
2+
3+ import androidx.lifecycle.LiveData
4+ import io.reactivex.BackpressureStrategy
5+ import io.reactivex.Observable
6+ import io.reactivex.Single
7+ import androidx.lifecycle.LiveDataReactiveStreams
8+
9+ fun <T > Observable<T>.toLiveData (backPressureStrategy : BackpressureStrategy = BackpressureStrategy .BUFFER ): LiveData <T > {
10+ return LiveDataReactiveStreams .fromPublisher(this .toFlowable(backPressureStrategy))
11+ }
12+
13+ fun <T > Single<T>.toLiveData (): LiveData <T > {
14+ return LiveDataReactiveStreams .fromPublisher(this .toFlowable()) // toFlowable 230ms
15+ }
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ dependencies {
2727 implementation fileTree(dir : ' libs' , include : [' *.jar' ])
2828 implementation " org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version "
2929 implementation ' androidx.appcompat:appcompat:1.0.2'
30- implementation ' androidx.core:core-ktx:1.0.2 '
30+ implementation " androidx.core:core-ktx:$a ndroid_core_ktx "
3131 testImplementation ' junit:junit:4.12'
3232 androidTestImplementation ' androidx.test:runner:1.2.0'
3333 androidTestImplementation ' androidx.test.espresso:espresso-core:3.2.0'
Original file line number Diff line number Diff line change 11// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
33buildscript {
4- ext. kotlin_version = ' 1.3.41'
4+ ext {
5+ kotlin_version = ' 1.3.41'
6+ rx_java = ' 2.2.9'
7+ rx_java_android = ' 2.1.1'
8+ android_core_ktx = ' 1.0.2'
9+ collection_ktx = ' 1.0.0'
10+ fragment_ktx = ' 1.0.0'
11+ lifecycle_reactivestreams_ktx = ' 2.1.0-rc01'
12+ }
513 repositories {
614 google()
715 jcenter()
You can’t perform that action at this time.
0 commit comments