File tree Expand file tree Collapse file tree 5 files changed +13
-8
lines changed
src/main/java/com/molo17/couchbase/lite Expand file tree Collapse file tree 5 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 11apply plugin : ' kotlin'
22apply plugin : ' maven-publish'
33
4+ version = ' 1.1.0'
5+
46dependencies {
57 def couchbaseLite = " com.couchbase.lite:couchbase-lite-java:2.7.0"
68
@@ -18,7 +20,7 @@ def mavPluginVersion = '1.0.3'
1820apply from : " https://raw.githubusercontent.com/sky-uk/gradle-maven-plugin/${ mavPluginVersion} /gradle-mavenizer.gradle"
1921
2022project. ext {
21- mavDevelopers = [" damiano" : " Damiano Giusti" ]
23+ mavDevelopers = [" damiano" : " Damiano Giusti" , " federico " : " Federico Monti " ]
2224 mavSiteUrl = " https://github.com/MOLO17/couchbase-lite-kotlin"
2325 mavGitUrl = mavSiteUrl + ' .git'
2426 mavProjectName = ' Couchbase Lite Kotlin'
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import com.couchbase.lite.Database
2020import com.couchbase.lite.DatabaseChange
2121import com.couchbase.lite.DocumentChange
2222import kotlinx.coroutines.channels.awaitClose
23+ import kotlinx.coroutines.channels.sendBlocking
2324import kotlinx.coroutines.flow.Flow
2425import kotlinx.coroutines.flow.callbackFlow
2526
@@ -29,7 +30,7 @@ import kotlinx.coroutines.flow.callbackFlow
2930 * @see Database.addChangeListener
3031 */
3132fun Database.changesFlow (): Flow <DatabaseChange > = callbackFlow {
32- val token = addChangeListener { change -> offer (change) }
33+ val token = addChangeListener { change -> sendBlocking (change) }
3334 awaitClose { removeChangeListener(token) }
3435}
3536
@@ -39,7 +40,7 @@ fun Database.changesFlow(): Flow<DatabaseChange> = callbackFlow {
3940 * @see Database.addDocumentChangeListener
4041 */
4142fun Database.documentChangesFlow (documentId : String ): Flow <DocumentChange > = callbackFlow {
42- val token = addDocumentChangeListener(documentId) { change -> offer (change) }
43+ val token = addDocumentChangeListener(documentId) { change -> sendBlocking (change) }
4344 awaitClose { removeChangeListener(token) }
4445}
4546
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import com.couchbase.lite.Query
2020import com.couchbase.lite.QueryChange
2121import com.couchbase.lite.ResultSet
2222import kotlinx.coroutines.channels.awaitClose
23+ import kotlinx.coroutines.channels.sendBlocking
2324import kotlinx.coroutines.flow.Flow
2425import kotlinx.coroutines.flow.callbackFlow
2526import kotlinx.coroutines.flow.map
@@ -53,7 +54,7 @@ fun Query.asFlow(): Flow<ResultSet> = asQueryFlow().map { it.results }
5354 * @param factory the lambda used for creating object instances.
5455 */
5556fun <T : Any > Query.asObjectsFlow (
56- factory : (Map <String , Any ?>) -> T
57+ factory : (Map <String , Any ?>) -> T ?
5758): Flow <List <T >> = asQueryFlow().map { queryChange -> queryChange.results.toObjects(factory) }
5859
5960// /////////////////////////////////////////////////////////////////////////
@@ -63,7 +64,7 @@ fun <T : Any> Query.asObjectsFlow(
6364private fun Query.asQueryFlow (): Flow <QueryChange > = callbackFlow {
6465 val token = addChangeListener { queryChange ->
6566 if (queryChange.error == null ) {
66- offer (queryChange)
67+ sendBlocking (queryChange)
6768 } else {
6869 throw queryChange.error
6970 }
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import com.couchbase.lite.DocumentReplication
2323import com.couchbase.lite.Replicator
2424import com.couchbase.lite.ReplicatorChange
2525import kotlinx.coroutines.channels.awaitClose
26+ import kotlinx.coroutines.channels.sendBlocking
2627import kotlinx.coroutines.flow.Flow
2728import kotlinx.coroutines.flow.callbackFlow
2829
@@ -32,7 +33,7 @@ import kotlinx.coroutines.flow.callbackFlow
3233 * @see Replicator.addChangeListener
3334 */
3435fun Replicator.changesFlow (): Flow <ReplicatorChange > = callbackFlow {
35- val token = addChangeListener { change -> offer (change) }
36+ val token = addChangeListener { change -> sendBlocking (change) }
3637 awaitClose { removeChangeListener(token) }
3738}
3839
@@ -42,7 +43,7 @@ fun Replicator.changesFlow(): Flow<ReplicatorChange> = callbackFlow {
4243 * @see Replicator.addDocumentReplicationListener
4344 */
4445fun Replicator.documentReplicationFlow (): Flow <DocumentReplication > = callbackFlow {
45- val token = addDocumentReplicationListener { replication -> offer (replication) }
46+ val token = addDocumentReplicationListener { replication -> sendBlocking (replication) }
4647 awaitClose { removeChangeListener(token) }
4748}
4849
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ import com.couchbase.lite.ResultSet
3939 * @param factory lambda used for creating an object instance
4040 * @return a [List] of objects of type [T]
4141 */
42- inline fun <T : Any > ResultSet.toObjects (factory : (Map <String , Any ?>) -> T ): List <T > =
42+ inline fun <T : Any > ResultSet.toObjects (factory : (Map <String , Any ?>) -> T ? ): List <T > =
4343 mapNotNull { result ->
4444 result.run {
4545
You can’t perform that action at this time.
0 commit comments