From 2f3796733d562b22c20b530df95473f8f62ad7c9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 26 Sep 2021 14:17:01 +0600 Subject: [PATCH] Hotfix for 0.6.5 flows --- .../dev/inmo/krontab/utils/SchedulerFlow.kt | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/commonMain/kotlin/dev/inmo/krontab/utils/SchedulerFlow.kt b/src/commonMain/kotlin/dev/inmo/krontab/utils/SchedulerFlow.kt index a14807c..7a1a78d 100644 --- a/src/commonMain/kotlin/dev/inmo/krontab/utils/SchedulerFlow.kt +++ b/src/commonMain/kotlin/dev/inmo/krontab/utils/SchedulerFlow.kt @@ -12,12 +12,12 @@ import kotlinx.coroutines.flow.* * time zones * * @see channelFlow - * @see KronSchedulerTz.doWhile + * @see KronSchedulerTz.doInfinityTz */ @FlowPreview -fun KronSchedulerTz.asTzFlow(): Flow = channelFlow { - doInfinity { - send(DateTime.nowLocal()) +fun KronScheduler.asTzFlow(): Flow = channelFlow { + doInfinityTz { + send(it) } } @@ -25,29 +25,15 @@ fun KronSchedulerTz.asTzFlow(): Flow = channelFlow { * This method is a map for [asTzFlow] and will works the same but return flow with [DateTime]s * * @see channelFlow - * @see KronScheduler.doWhile + * @see KronScheduler.doInfinityLocal */ @FlowPreview fun KronScheduler.asFlow(): Flow = channelFlow { - doInfinity { - send(DateTime.now()) + doInfinityLocal { + send(it) } } -/** - * This [Flow] will trigger emitting each near time which will be returned from [this] [KronScheduler] with attention to - * time zones - * - * @see channelFlow - * @see KronScheduler.asFlow - * @see KronSchedulerTz.asTzFlow - */ -@FlowPreview -fun KronScheduler.asTzFlow(): Flow = when (this) { - is KronSchedulerTz -> asTzFlow() - else -> asFlow().map { it.local } -} - @Deprecated( "It is not recommended to use this class in future. This functionality will be removed soon", ReplaceWith("asFlow", "dev.inmo.krontab.utils.asFlow")