jw
01/01/2018, 4:11 AMdave08
01/01/2018, 5:56 AMjw
01/01/2018, 6:02 AMdave08
01/01/2018, 6:09 AMjw
01/01/2018, 6:12 AMdave08
01/01/2018, 7:33 AMdelay
is maybe a tricky name....louiscad
01/01/2018, 10:06 PMyield()
do the trick?jw
01/02/2018, 12:02 AMdave08
01/02/2018, 3:54 AMprivate val executor = Executors.newSingleThreadScheduledExecutor {
Thread(it, "scheduler").apply { isDaemon = true }
}
suspend fun delay(time: Long, unit: TimeUnit = TimeUnit.MILLISECONDS): Unit = suspendCoroutine { cont ->
executor.schedule({ cont.resume(Unit) }, time, unit)
}
You're probably aware of this, I'm just wondering for myself, I view the code as avoiding the step consumer that Rx would do behind the scenes...jw
01/02/2018, 4:10 AMdave08
01/02/2018, 7:21 AMsample
or similar... if you actually implement something, I'd be very interested in seeing it... thanks @jw!