Is it possible to have a delayed Schedule before t...
# arrow
k
Is it possible to have a delayed Schedule before the first attempt only ? I thought something like this would work but i triggers the function eagerly immediately:
Copy code
private suspend fun scheduleWithInitialDelay(job: Job, block: suspend () -> Unit) {
    // Repeat every 5 minutes
    Schedule.spaced<Unit>(job.fixedInterval)
        .delayed { attempt, _ ->
            // Delay by 1 minute only for the first attempt
            if (attempt == 0L) job.initialDelay else ZERO
        }
        .repeat { block() }
}
s
So do you want to simply delay your first attempt? Does adding a simple delay first thing in the function do what you want here?
k
Yeah, as described inline. Only an initial delay before a fixed schedule kicks in. Delaying in the function would also delay all subsequent calls which i want to avoid
s
So you want the action to run on minutes: 1 - 5 - 10 - 15 - 20 But not 0 - 5 - 10 - 15 - 20 or 1 - 6 - 11 - 16 - 21