mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-29 13:38:50 +00:00
commit
9a10c7eb87
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,5 +1,15 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2.1.1
|
||||||
|
|
||||||
|
* `asFlowWithoutDelays` and `asTzFlowWithoutDelays` will have nullable `since` parameters with default to `null`
|
||||||
|
to avoid any inconsistency of `Flow` idiom.
|
||||||
|
<details>
|
||||||
|
<summary>About the reason of changes</summary>
|
||||||
|
Cold flows should not contain some state by default. So, it was not right to save some `DateTime`/`DateTimeTz`
|
||||||
|
by default. Now it will not use some external state unless developers will set it manually
|
||||||
|
</details>
|
||||||
|
|
||||||
## 2.1.0
|
## 2.1.0
|
||||||
|
|
||||||
* Versions
|
* Versions
|
||||||
|
@ -36,5 +36,5 @@ androidx_work_version=2.8.1
|
|||||||
|
|
||||||
## Common
|
## Common
|
||||||
|
|
||||||
version=2.1.0
|
version=2.1.1
|
||||||
android_code_version=27
|
android_code_version=28
|
||||||
|
@ -18,10 +18,11 @@ import kotlinx.coroutines.isActive
|
|||||||
* Will emit all the [KronScheduler.next] as soon as possible. In case [KronScheduler.next] return null, flow will
|
* Will emit all the [KronScheduler.next] as soon as possible. In case [KronScheduler.next] return null, flow will
|
||||||
* be completed
|
* be completed
|
||||||
*
|
*
|
||||||
* @param since Will be used as the first parameter for [KronScheduler.next] fun
|
* @param since Will be used as the first parameter for [KronScheduler.next] fun. If passed null, `flow`
|
||||||
|
* will always start since the moment of collecting start
|
||||||
*/
|
*/
|
||||||
fun KronScheduler.asTzFlowWithoutDelays(since: DateTimeTz = DateTime.nowLocal()): Flow<DateTimeTz> = flow {
|
fun KronScheduler.asTzFlowWithoutDelays(since: DateTimeTz? = null): Flow<DateTimeTz> = flow {
|
||||||
var previous = since
|
var previous = since ?: DateTime.nowLocal()
|
||||||
while (currentCoroutineContext().isActive) {
|
while (currentCoroutineContext().isActive) {
|
||||||
val next = next(previous) ?: break
|
val next = next(previous) ?: break
|
||||||
emit(next)
|
emit(next)
|
||||||
@ -57,10 +58,11 @@ fun KronScheduler.asTzFlow(): Flow<DateTimeTz> = asTzFlowWithDelays()
|
|||||||
* Will emit all the [KronScheduler.next] as soon as possible. In case [KronScheduler.next] return null, flow will
|
* Will emit all the [KronScheduler.next] as soon as possible. In case [KronScheduler.next] return null, flow will
|
||||||
* be completed
|
* be completed
|
||||||
*
|
*
|
||||||
* @param since Will be used as the first parameter for [KronScheduler.next] fun
|
* @param since Will be used as the first parameter for [KronScheduler.next] fun. If passed null, `flow`
|
||||||
|
* will always start since the moment of collecting start
|
||||||
*/
|
*/
|
||||||
fun KronScheduler.asFlowWithoutDelays(since: DateTime = DateTime.now()): Flow<DateTime> = flow {
|
fun KronScheduler.asFlowWithoutDelays(since: DateTime? = null): Flow<DateTime> = flow {
|
||||||
var previous = since
|
var previous = since ?: DateTime.now()
|
||||||
while (currentCoroutineContext().isActive) {
|
while (currentCoroutineContext().isActive) {
|
||||||
val next = next(previous) ?: break
|
val next = next(previous) ?: break
|
||||||
emit(next)
|
emit(next)
|
||||||
|
Loading…
Reference in New Issue
Block a user