myanmarking
01/08/2020, 10:43 AMdiesieben07
01/08/2020, 10:46 AMAtomicReference
and you can just use a normal var
.
You can also further simplify this operator:
fun <T> Flow<T>.delayFirst(
time: Long,
timeUnit: TimeUnit = TimeUnit.MILLISECONDS
): Flow<T> {
return this.onStart { delay(timeUnit.toMillis(time)) }
}
myanmarking
01/08/2020, 10:47 AMdiesieben07
01/08/2020, 10:48 AMmyanmarking
01/08/2020, 10:50 AMdiesieben07
01/08/2020, 10:51 AMgetAndSet(false
, which returns true. Therefor you then delay, before emitting the first element.
On all subsequent elements getAndSet(false
returns false
, meaning no delay.