richodemus
09/05/2018, 2:49 PMdelay
so like this:
launch {
println("This is called right away")
delay(1, YEARS)
println("I want this to happen when a criteria is met")
}
if(criteria) {
cancelDelay()
}
marstran
09/05/2018, 2:52 PMrichodemus
09/05/2018, 2:55 PMrichodemus
09/05/2018, 2:55 PMmarstran
09/05/2018, 2:55 PMSeri
09/05/2018, 2:56 PMmarstran
09/05/2018, 3:00 PMval ch = actor<Int> {
println("This is called right away")
// Suspends until there's a message on the channel
val ping = channel.receive()
println("I want this to happen when a criteria is met")
}
runBlocking {
delay(1000)
if (criteria) {
ch.send(0)
}
}
bj0
09/05/2018, 3:39 PMChannel
fits best. An actor
is one way to use a channelbj0
09/05/2018, 3:40 PMCompletableDeferred
is also an optiongildor
09/06/2018, 1:44 AMactor<Int> {
println("This is called right away")
launch(coroutineContext) {
delay(1, YEARS)
send(someActorData)
}
val ping = channel.receive()
println("I want this to happen when a criteria is met")
}
richodemus
09/06/2018, 8:53 AM