From 68be768763e28b8ef7483e10792ccf05da0588ae Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 21 Mar 2024 17:14:59 +0600 Subject: [PATCH 1/2] start 2.3.0 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9638cd8..f73fe21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 2.3.0 + ## 2.2.9 * `Version`: diff --git a/gradle.properties b/gradle.properties index c6f1112..fef0e73 100644 --- a/gradle.properties +++ b/gradle.properties @@ -36,5 +36,5 @@ androidx_work_version=2.9.0 ## Common -version=2.2.9 -android_code_version=39 +version=2.3.0 +android_code_version=40 From 36671cb379e1683fcbf46c32ff58aa8154558f8e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 21 Mar 2024 17:34:22 +0600 Subject: [PATCH 2/2] potential fix of #107 --- CHANGELOG.md | 2 ++ src/commonMain/kotlin/Executes.kt | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f73fe21..fda6290 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 2.3.0 +* `doWhile` now will guarantee that it will not call `doOnce` more than once for time + ## 2.2.9 * `Version`: diff --git a/src/commonMain/kotlin/Executes.kt b/src/commonMain/kotlin/Executes.kt index 35356b3..90a31ba 100644 --- a/src/commonMain/kotlin/Executes.kt +++ b/src/commonMain/kotlin/Executes.kt @@ -71,9 +71,18 @@ suspend inline fun doOnceTz( * Will execute [block] while it will return true as a result of its calculation */ suspend inline fun KronScheduler.doWhile(block: (DateTime) -> Boolean) { + var latest: DateTime? = null do { delay(1L) - } while (doOnce(block)) + val result = doOnce { + if (latest != it) { + latest = it + block(it) + } else { + null + } + } + } while (result == null || result) } /** * Will execute [block] while it will return true as a result of its calculation @@ -85,9 +94,18 @@ suspend inline fun KronScheduler.doWhileLocal(block: (DateTime) -> Boolean) = do * Will execute [block] while it will return true as a result of its calculation */ suspend inline fun KronScheduler.doWhileTz(noinline block: suspend (DateTimeTz) -> Boolean) { + var latest: DateTimeTz? = null do { delay(1L) - } while (doOnceTz(block)) + val result = doOnceTz { + if (latest != it) { + latest = it + block(it) + } else { + null + } + } + } while (result == null || result) } /**