Skip to content

Commit 3d27411

Browse files
committed
add flowExt
1 parent 6da972b commit 3d27411

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ dependencies {
102102

103103
implementation(deps.listenableFuture)
104104
implementation(deps.viewBindingDelegate)
105+
implementation(deps.flowExt)
105106
}
106107

107108
apply {

app/src/main/java/com/hoc/comicapp/data/repository/DownloadComicsRepositoryImpl.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import com.hoc.comicapp.domain.thread.RxSchedulerProvider
4141
import com.hoc.comicapp.utils.copyTo
4242
import com.hoc.comicapp.utils.retryIO
4343
import com.hoc.comicapp.worker.DownloadComicWorker
44+
import com.hoc081098.flowext.utils.NULL_VALUE
4445
import io.reactivex.rxjava3.core.Observable
4546
import kotlinx.coroutines.ExperimentalCoroutinesApi
4647
import kotlinx.coroutines.flow.Flow
@@ -457,12 +458,6 @@ private fun String.escapeFileName(): String {
457458
)
458459
}
459460

460-
private object NULL {
461-
@Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE")
462-
inline fun <T : Any?> unbox(value: Any?): T =
463-
if (NULL === value) null as T else value as T
464-
}
465-
466461
/**
467462
* Collects all the values from the given flow, transform them by [transformer] and emits them to the [collector].
468463
* It is a shorthand for `flow.collect { value -> emit(value) }`.
@@ -473,10 +468,10 @@ private suspend fun <T, R> Flow<T>.emitAllTo(
473468
collector: FlowCollector<R>,
474469
transformer: (T) -> R,
475470
): T? {
476-
var last: Any? = NULL
471+
var last: Any? = NULL_VALUE
477472
collect {
478473
last = it
479474
collector.emit(transformer(it))
480475
}
481-
return NULL.unbox(last)
476+
return NULL_VALUE.unbox(last)
482477
}

buildSrc/src/main/kotlin/Configurations.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ object versions {
8787
const val arrow = "1.1.2"
8888
const val uri = "0.3.3"
8989
const val viewBindingDelegate = "1.3.1"
90+
const val flowExt = "0.3.0-SNAPSHOT"
9091
}
9192

9293
object deps {
@@ -211,6 +212,7 @@ object deps {
211212
}
212213

213214
const val listenableFuture = "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava"
215+
const val flowExt = "io.github.hoc081098:FlowExt:${versions.flowExt}"
214216
const val viewBindingDelegate = "com.github.hoc081098:ViewBindingDelegate:${versions.viewBindingDelegate}"
215217
}
216218

0 commit comments

Comments
 (0)