Scala.js中的未來可以睡在裏面嗎? 喜歡的東西: Future {
Thread.sleep(1000)
println("ready")
}
如果我試試這個,然後我得到一個異常說sleep方法不存在。 看起來好像有可能睡在JS:What is the JavaScript version of sleep()?即使不可能阻止。
什麼是實現類似元組解包與期貨類似的方式/習慣用法? 我有一個像 a, b, c = f(x)
y = g(a, b)
z = h(y, c)
代碼,我想將其轉換爲利用期貨。 理想我想寫點東西像 a, b, c = ex.submit(f, x)
y = ex.submit(g, a, b)
z = ex.submit(h, y, c)
的第一行拋出 TypeError: 'Futu
我有一個在單獨的線程中運行的函數。調用該函數的代碼不等它的結果。 def sendEmail(email: String): Future[Unit] = {
...
}
def registration: Future[User] = {
...
// I do not want to wait for result of this function, jus
使用Akka的調度程序時,我遇到了一個奇怪的行爲。我的代碼看起來大致是這樣的: val s = ActorSystem("scheduler")
import scala.concurrent.ExecutionContext.Implicits.global
def doSomething(): Future[Unit] = {
val now = new G