Skip to content

Commit

Permalink
Merge pull request #4 from tamimattafi/bug/single_element_flow_#3
Browse files Browse the repository at this point in the history
fix: behaviour of flow with single element #3

close #3
  • Loading branch information
tamimattafi authored Mar 24, 2024
2 parents 94de1ea + 3fdd367 commit ab0d53b
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 64 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Kabin Release](https://img.shields.io/github/release/tamimattafi/kabin.svg?style=for-the-badge&color=green)](https://github.com/tamimattafi/kabin/releases)
[![Kabin Release](https://img.shields.io/github/release/tamimattafi/kabin.svg?style=for-the-badge&color=darkgreen)](https://github.com/tamimattafi/kabin/releases)
[![Kotlin](https://img.shields.io/github/languages/top/tamimattafi/kabin.svg?style=for-the-badge&color=blueviolet)](https://kotlinlang.org/)
[![License Apache 2.0](https://img.shields.io/github/license/tamimattafi/kabin.svg?style=for-the-badge&color=purple)](https://github.com/tamimattafi/kabin/blob/main/LICENSE)

Expand Down Expand Up @@ -75,7 +75,7 @@ For more advanced topics, read [Room](https://developer.android.com/training/dat
## Installation
Latest Kabin version

[![Kabin Release](https://img.shields.io/github/release/tamimattafi/kabin.svg?style=for-the-badge&color=green)](https://github.com/tamimattafi/kabin/releases)
[![Kabin Release](https://img.shields.io/github/release/tamimattafi/kabin.svg?style=for-the-badge&color=darkgreen)](https://github.com/tamimattafi/kabin/releases)

Add `common` modules to your `sourceSet`:
```kotlin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.gradle.api.publish.maven.MavenPomScm

class PublishConventions : Plugin<Project> {

private val version = "0.1.0-alpha01"
private val version = "0.1.0-alpha02"
private val group = "com.attafitamim.kabin"

override fun apply(project: Project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ class DaoGenerator(
is DataTypeSpec.DataType.Data -> if (type.nestedTypeSpec.isNullable) {
"asFlowIONullable"
} else {
"asFlowIONotNull"
"asFlowIO"
}

is DataTypeSpec.DataType.Stream -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import app.cash.sqldelight.SuspendingTransactionWithReturn
import app.cash.sqldelight.SuspendingTransactionWithoutReturn
import app.cash.sqldelight.coroutines.asFlow
import app.cash.sqldelight.coroutines.mapToList
import app.cash.sqldelight.coroutines.mapToOneNotNull
import app.cash.sqldelight.coroutines.mapToOne
import app.cash.sqldelight.coroutines.mapToOneOrNull
import com.attafitamim.kabin.core.utils.IO
import com.attafitamim.kabin.core.utils.awaitAll
Expand Down Expand Up @@ -53,8 +53,8 @@ interface KabinDao<T : SuspendingTransacter> {
fun <T : Any> Query<T>.asFlowIONullable(): Flow<T?> =
asFlow().mapToOneOrNull(Dispatchers.IO)

fun <T : Any> Query<T>.asFlowIONotNull(): Flow<T> =
asFlow().mapToOneNotNull(Dispatchers.IO)
fun <T : Any> Query<T>.asFlowIO(): Flow<T> =
asFlow().mapToOne(Dispatchers.IO)

fun <T, R> Flow<T>.mapIO(transform: suspend (value: T) -> R): Flow<R> = map { value ->
withContextIO {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import com.attafitamim.kabin.local.entities.data.CarPurchase
import com.attafitamim.kabin.local.entities.data.Gender
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch

class Playground(
private val configuration: KabinDatabaseConfiguration
) {

val scope = CoroutineScope(Job() + Dispatchers.IO)
val scope = CoroutineScope(Dispatchers.Default)
private val database: SampleDatabase by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
SampleDatabase::class.newInstance(
configuration,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit ab0d53b

Please sign in to comment.