From 18c608f569ad60f3b69ce24ee6a6e1d8e8e48aba Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 4 Dec 2024 10:16:19 +0600 Subject: [PATCH] small improvement in AccumulatorFlow --- CHANGELOG.md | 3 +++ .../kotlin/dev/inmo/micro_utils/coroutines/AccumulatorFlow.kt | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd26cf597d0..915ebe28ae6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.23.2 +* `Coroutines`: + * Small refactor in `AccumulatorFlow` to use `runCatching` instead of `runCatchingSafely` + ## 0.23.1 * `Versions`: diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/AccumulatorFlow.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/AccumulatorFlow.kt index 8485228026c..eb299f8ca47 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/AccumulatorFlow.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/AccumulatorFlow.kt @@ -68,9 +68,9 @@ class AccumulatorFlow( override suspend fun collectSafely(collector: FlowCollector) { val channel = Channel(Channel.UNLIMITED, BufferOverflow.SUSPEND) steps.send(SubscribeAccumulatorFlowStep(channel)) - val result = runCatchingSafely { + val result = runCatching { for (data in channel) { - val emitResult = runCatchingSafely { + val emitResult = runCatching { collector.emit(data) } if (emitResult.isSuccess || emitResult.exceptionOrNull() is CancellationException) {