laterOneJob

fun laterOneJob(name: String, job: () -> Unit)

Enqueue a job to run, but do not enqueue the same job (by name) if its already in the queue. This is useful if your job handles the "latest" state anyway. For example let's say you are updating a counter and want to do something (maybe save to disk) whenever the counter 100 (flush to disk every 100 updates). Using this function, every time I increment the counter, I can check and then launch the save in a separate thread. If you just used laterJob() you might enqueue 20 saves before the first one ran and set the counter back to 0. (yes this example is contrived and there's an easy workaround) counter += 1 if (counter 100) laterOneJob("flushCheck") { save(); counter = 0 }