Working with time
jmfayard opened this issue · comments
Hello, I've always found the java-esque way of working with time a bit annoying (I like to read and write from left to right ; it's not really completion-friendly)
val delay = TimeUnit.SECONDS.toMillis(30)
val single = Single.just(1).delaySubscription(10, TimeUnit.SECONDS, testScheduler)
I created for myself extensions that can be used like this
val delay = 30.seconds
val single = just(1).delaySubscription(10.seconds, testScheduler)
testScheduler.advanceTimeTo(20.seconds)
see
https://github.com/jmfayard/okAndroid/commit/e82b03caf2c57ee9a14236f801ce495a0c65f737
Would that be outside the scope of this project to add this kind of extensions?
I would be supportive of adding an artifact with an overload that takes Duration for Java 8 users. The factory property that creates a Duration from 10.seconds
does not belong in this project.
Yes, this would be an entirely new artifact targeting Java 8. However I can't prioritize such an initiative right now, so anyone else is welcome.
With the advent of the (experimental) kotlin.time.Duration
, this would solve both the issues of not having to have a new artifact targeting Java 8, and being able to write durations in readable formats (e.g. 10.seconds
).