File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## 2.3.0
4
4
5
+ * ` doWhile ` now will guarantee that it will not call ` doOnce ` more than once for time
6
+
5
7
## 2.2.9
6
8
7
9
* ` Version ` :
Original file line number Diff line number Diff line change @@ -71,9 +71,18 @@ suspend inline fun <T> doOnceTz(
71
71
* Will execute [block] while it will return true as a result of its calculation
72
72
*/
73
73
suspend inline fun KronScheduler.doWhile (block : (DateTime ) -> Boolean ) {
74
+ var latest: DateTime ? = null
74
75
do {
75
76
delay(1L )
76
- } while (doOnce(block))
77
+ val result = doOnce {
78
+ if (latest != it) {
79
+ latest = it
80
+ block(it)
81
+ } else {
82
+ null
83
+ }
84
+ }
85
+ } while (result == null || result)
77
86
}
78
87
/* *
79
88
* 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
85
94
* Will execute [block] while it will return true as a result of its calculation
86
95
*/
87
96
suspend inline fun KronScheduler.doWhileTz (noinline block : suspend (DateTimeTz ) -> Boolean ) {
97
+ var latest: DateTimeTz ? = null
88
98
do {
89
99
delay(1L )
90
- } while (doOnceTz(block))
100
+ val result = doOnceTz {
101
+ if (latest != it) {
102
+ latest = it
103
+ block(it)
104
+ } else {
105
+ null
106
+ }
107
+ }
108
+ } while (result == null || result)
91
109
}
92
110
93
111
/* *
You can’t perform that action at this time.
0 commit comments