Result values, both anonymous and named, are updated when complete. Even works with flatMap
. Amazing!
import scala.concurrent._
implicit val ec = ExecutionContext.global
Future(println("Hello"))
Future(3)
Thread.sleep(1000)
Future{Thread.sleep(3000); 3}
Future{Thread.sleep(10000); 30}
Future{Thread.sleep(3000); 3 ; println("completed")}
val n = 3
val fut = Future{Thread.sleep(3000); n}
val fut = Future{Thread.sleep(3000); 3}
val fut1 = fut.flatMap{k => Future{Thread.sleep(5000); k * k}}
val futVec = (1 to 10).toVector.map(n => Future{Thread.sleep(1000 * n); n})
val allDone = Future.sequence(futVec)
import sys.process._
println("git log -1".!!)
import $ivy.`io.monix::monix:3.0.0`
import monix.eval._
Task(3)
val task3 = Task.deferFuture(Future{Thread.sleep(6000); 3}(ec)).memoize
import monix.execution.Scheduler.Implicits.global
val fut3 = task3.runToFuture
task3
task3.runToFuture
val id = java.util.UUID.randomUUID().toString
kernel.publish.html("Starting", id)
for (i <- 1 to 10) {
Thread.sleep((200.0 + 200.0 * scala.util.Random.nextGaussian).toLong max 0L)
kernel.publish.updateHtml(s"Got item <b>#$i</b>", id)
}
kernel.publish.updateHtml("Got all items", id)
for (i <- 1 to 10) {
kernel.publish.html(s"Got item <b>#$i</b>")
Thread.sleep((200.0 + 200.0 * scala.util.Random.nextGaussian).toLong max 0L)
}
import almond.display._
Html("<b>Bold stuff</b>")
val handle = Html("<p> stuff comes here </p>")
handle.withContent("<b>Stuff becomes bold</b>").update()
val svgText = """<svg version="1.1"
baseProfile="full"
width="300" height="200"
xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="red" />
<circle cx="150" cy="100" r="80" fill="green" />
<text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text>
</svg>"""
Html(svgText)
Future{Thread.sleep(5000); handle.withContent(svgText).update() }(ec)
handle.data
handle.displayId
handle.url
handle.contentOrUrl
handle.metadata
interp
interp.repositories
Image
Image.JPG