What is the recommended way to make Clock aware of...
# kotlinx-datetime
c
What is the recommended way to make Clock aware of the Coroutines.Test delay skipping?
m
I'm guessing is that you would want to create your own implementation of `Clock`that wraps or can access a
TestCoroutineScheduler
and use its
currentTime
property. That way your clock always matches the time of the coroutine.
c
It's surprisingly easier than I expected it to be:
Copy code
class TestClock(private val scheduler: TestCoroutineScheduler) : Clock {
	override fun now(): Instant = Instant.fromEpochMilliseconds(scheduler.currentTime)
}
It would be nice if it was available out-of-the-box though
m
The two libraries don't depend on each other, and I think it is better that they don't. Less dependency management.