Hotfix for 0.6.5 flows

This commit is contained in:
InsanusMokrassar 2021-09-26 14:17:01 +06:00 committed by GitHub
parent 89a6a305f8
commit 2f3796733d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 21 deletions

View File

@ -12,12 +12,12 @@ import kotlinx.coroutines.flow.*
* time zones
*
* @see channelFlow
* @see KronSchedulerTz.doWhile
* @see KronSchedulerTz.doInfinityTz
*/
@FlowPreview
fun KronSchedulerTz.asTzFlow(): Flow<DateTimeTz> = channelFlow {
doInfinity {
send(DateTime.nowLocal())
fun KronScheduler.asTzFlow(): Flow<DateTimeTz> = channelFlow {
doInfinityTz {
send(it)
}
}
@ -25,29 +25,15 @@ fun KronSchedulerTz.asTzFlow(): Flow<DateTimeTz> = 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<DateTime> = 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<DateTimeTz> = 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")