Show that a callback runs after work is ready.

Callback Order

CallbackOrder.scala
object Main {
  def main(args: Array[String]): Unit = {
    val done = 
    var log = "scheduled"
    var state = "waiting"

    if (done) {
      log = log + ">callback"
      state = "updated"
    }

    println("log=" + log)
    println("state=" + state)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val done = 
    var log = "scheduled"
    var state = "waiting"

    if (done) {
      log = log + ">callback"
      state = "updated"
    }

    println("log=" + log)
    println("state=" + state)
  }
}
callback-order A callback is code saved for a later state. The replay keeps the idea deterministic by changing local state instead of starting a background task.