Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

CountDownTimer top-level function #538

Open
romtsn opened this issue May 13, 2018 · 0 comments
Open

CountDownTimer top-level function #538

romtsn opened this issue May 13, 2018 · 0 comments

Comments

@romtsn
Copy link
Contributor

romtsn commented May 13, 2018

I think most of the time folks use CountDownTimer with 1s interval and only onTick callback. So we could use a default parameter for interval (also probably for starting the timer) and a lambda as last parameter for onTick. With that the following top-level function might exist:

fun countDownTimer(
    millisInFuture: Long,
    interval: Long = 1000,
    start: Boolean = true,
    onFinish: () -> Unit = {},
    onTick: (Long) -> Unit
): CountDownTimer 

And the usage is a lot simplified after that:

val timer = countDownTimer(10_000) {
    // onTick
    // it - the amount of time until finished.
}

What do you think about this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant