Skip to content

Commit 430cdd9

Browse files
authored
Merge pull request #3 from eadm/domain-rx-1.0.0
add domain rx
2 parents a891060 + a55ddf5 commit 430cdd9

File tree

11 files changed

+199
-0
lines changed

11 files changed

+199
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ dependencies {
4747
}
4848
```
4949

50+
### domain-rx
51+
[ ![Download](https://api.bintray.com/packages/eadm/ru.nobird.android/ru.nobird.android.domain/images/download.svg) ](https://bintray.com/eadm/ru.nobird.android/ru.nobird.android.domain/_latestVersion)
52+
53+
Расширения для работы с RxJava
54+
55+
```groovy
56+
dependencies {
57+
implementation 'ru.nobird.android.domain:rx:x.y.z'
58+
}
59+
```
60+
5061
### presentation-base
5162
[ ![Download](https://api.bintray.com/packages/eadm/ru.nobird.android/ru.nobird.android.presentation/images/download.svg) ](https://bintray.com/eadm/ru.nobird.android/ru.nobird.android.presentation/_latestVersion)
5263

dependencies.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ext.versions = [
77
viewInjectionName : '1.0.0',
88

99
presentationBaseName : '1.1.1',
10+
domainRxName : '1.0.0',
1011

1112
minSdk : 16,
1213
targetSdk : 29,

domain-rx/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

domain-rx/build.gradle

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
4+
apply plugin: 'com.github.dcendents.android-maven'
5+
apply plugin: 'com.jfrog.bintray'
6+
7+
android {
8+
compileSdkVersion versions.compileSdk
9+
buildToolsVersion versions.buildTools
10+
11+
defaultConfig {
12+
minSdkVersion versions.minSdk
13+
targetSdkVersion versions.targetSdk
14+
versionCode versions.code
15+
versionName versions.domainRxName
16+
17+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
18+
19+
}
20+
21+
buildTypes {
22+
release {
23+
minifyEnabled false
24+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25+
}
26+
}
27+
}
28+
29+
dependencies {
30+
implementation libraries.kotlin
31+
implementation libraries.rxJava2
32+
}
33+
34+
ext {
35+
bintrayRepo = 'ru.nobird.android'
36+
bintrayName = 'ru.nobird.android.domain'
37+
38+
publishedGroupId = 'ru.nobird.android.domain'
39+
libraryName = 'Domain-Rx'
40+
artifact = 'rx'
41+
42+
libraryDescription = 'Collection of rx domain extensions'
43+
44+
siteUrl = 'https://github.com/eadm/AndroidKit/domain-rx'
45+
gitUrl = 'https://github.com/eadm/AndroidKit/domain-rx'
46+
47+
libraryVersion = versions.domainRxName
48+
49+
developerId = 'eadm'
50+
developerName = 'Ruslan Davletshin'
51+
developerEmail = '[email protected]'
52+
53+
licenseName = 'The Apache Software License, Version 2.0'
54+
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
55+
allLicenses = ["Apache-2.0"]
56+
}
57+
58+
apply from: "../bintray.gradle"

domain-rx/consumer-rules.pro

Whitespace-only changes.

domain-rx/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package ru.nobird.android.domain.rx
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("ru.nobird.android.domain.rx.test", appContext.packageName)
23+
}
24+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="ru.nobird.android.domain.rx">
3+
4+
/
5+
</manifest>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package ru.nobird.android.domain.rx
2+
3+
import io.reactivex.Completable
4+
import io.reactivex.Maybe
5+
import io.reactivex.Observable
6+
import io.reactivex.Single
7+
8+
inline fun <T> Maybe<T>.doCompletableOnSuccess(crossinline completableSource: (T) -> Completable): Maybe<T> =
9+
flatMap { completableSource(it).andThen(Maybe.just(it)) }
10+
11+
inline fun <T> Single<T>.doCompletableOnSuccess(crossinline completableSource: (T) -> Completable): Single<T> =
12+
flatMap { completableSource(it).andThen(Single.just(it)) }
13+
14+
/**
15+
* Check list for size or return error
16+
*/
17+
fun <T> Single<List<T>>.requireSize(size: Int): Single<List<T>> =
18+
flatMap { list ->
19+
list.takeIf { it.size == size }
20+
?.let { Single.just(it) }
21+
?: Single.error(IllegalStateException("Expected list size = $size, actual = ${list.size}"))
22+
}
23+
24+
/**
25+
* Empty on error stub in order to suppress errors
26+
*/
27+
val emptyOnErrorStub: (Throwable) -> Unit = {}
28+
29+
/**
30+
* Filters observable according to [predicateSource] predicate
31+
*/
32+
fun <T> Observable<T>.filterSingle(predicateSource: (T) -> Single<Boolean>): Observable<T> =
33+
flatMap { item ->
34+
predicateSource(item)
35+
.toObservable()
36+
.filter { it }
37+
.map { item }
38+
}
39+
40+
/**
41+
* Wraps current object to Maybe
42+
*/
43+
fun <T : Any> T?.toMaybe(): Maybe<T> =
44+
if (this == null) {
45+
Maybe.empty()
46+
} else {
47+
Maybe.just(this)
48+
}
49+
50+
/**
51+
* Returns first element of list wrapped in Maybe or empty
52+
*/
53+
fun <T : Any> Single<List<T>>.maybeFirst(): Maybe<T> =
54+
flatMapMaybe { it.firstOrNull().toMaybe() }
55+
56+
/**
57+
* Returns first element of list
58+
*/
59+
fun <T : Any> Single<List<T>>.first(): Single<T> =
60+
map { it.first() }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package ru.nobird.android.domain.rx
2+
3+
import org.junit.Test
4+
5+
import org.junit.Assert.*
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* See [testing documentation](http://d.android.com/tools/testing).
11+
*/
12+
class ExampleUnitTest {
13+
@Test
14+
fun addition_isCorrect() {
15+
assertEquals(4, 2 + 2)
16+
}
17+
}

0 commit comments

Comments
 (0)