Skip to content

Commit a0a4502

Browse files
Add Kotlin extensions to build Rx types, requires Java 8 for Kotlin library.
1 parent 2fdf973 commit a0a4502

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

objectbox-kotlin/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ buildscript {
2020
apply plugin: 'kotlin'
2121
apply plugin: 'org.jetbrains.dokka'
2222

23-
sourceCompatibility = 1.7
23+
sourceCompatibility = 1.8
2424

2525
dokka {
2626
outputFormat = 'html'
@@ -58,6 +58,7 @@ dependencies {
5858
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
5959

6060
compile project(':objectbox-java')
61+
compileOnly project(':objectbox-rxjava3')
6162
}
6263

6364

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.objectbox.kotlin
2+
3+
import io.objectbox.query.Query
4+
import io.objectbox.rx3.RxQuery
5+
import io.reactivex.rxjava3.core.BackpressureStrategy
6+
import io.reactivex.rxjava3.core.Flowable
7+
import io.reactivex.rxjava3.core.Observable
8+
import io.reactivex.rxjava3.core.Single
9+
10+
/**
11+
* Shortcut for [`RxQuery.flowableOneByOne(query, strategy)`][RxQuery.flowableOneByOne].
12+
*/
13+
fun <T> Query<T>.flowableOneByOne(strategy: BackpressureStrategy = BackpressureStrategy.BUFFER): Flowable<T> {
14+
return RxQuery.flowableOneByOne(this, strategy)
15+
}
16+
17+
/**
18+
* Shortcut for [`RxQuery.observable(query)`][RxQuery.observable].
19+
*/
20+
fun <T> Query<T>.observable(): Observable<MutableList<T>> {
21+
return RxQuery.observable(this)
22+
}
23+
24+
/**
25+
* Shortcut for [`RxQuery.single(query)`][RxQuery.single].
26+
*/
27+
fun <T> Query<T>.single(): Single<MutableList<T>> {
28+
return RxQuery.single(this)
29+
}

0 commit comments

Comments
 (0)