Created
March 25, 2014 14:24
-
-
Save mizchi/9762923 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.scalajs.js | |
import scala.scalajs.js.Dynamic.{global, literal} | |
import js.annotation.JSExport | |
import scala.concurrent.{Promise, Future} | |
import scala.util.{Failure, Success} | |
import scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow | |
@JSExport | |
object Main { | |
def defer:Future[Int] = { | |
val promise = Promise[Int] | |
global.setTimeout(() => {promise.success(3)}, 100) | |
return promise.future | |
} | |
@JSExport | |
def main(): Unit = { | |
defer onSuccess { | |
case num => println(num) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment