You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
44 lines
1.2 KiB
// package outwatchapp.util
|
|
|
|
// import org.scalajs.dom
|
|
|
|
// import scala.scalajs.js
|
|
// import scala.scalajs.js.annotation.JSExport
|
|
// import org.scalajs.dom.webworkers.DedicatedWorkerGlobalScope
|
|
// import scala.scalajs.js.annotation.JSGlobalScope
|
|
// import scala.scalajs.js.annotation.JSExportTopLevel
|
|
|
|
// // @js.native
|
|
// // object WorkerGlobal extends js.GlobalScope {
|
|
// // def addEventListener(`type`: String, f: js.Function): Unit = js.native
|
|
// // def postMessage(data: js.Any): Unit = js.native
|
|
// // }
|
|
|
|
// @js.native
|
|
// @JSGlobalScope
|
|
// object WorkerGlobal extends DedicatedWorkerGlobalScope
|
|
|
|
// @JSExportTopLevel("WorkerMain")
|
|
// object WorkerMain {
|
|
// @JSExport
|
|
// def main(): Unit = {
|
|
// // WorkerGlobal.addEventListener("message", onMessage _)
|
|
// WorkerGlobal.onmessage = onMessage _
|
|
// WorkerGlobal.postMessage(s"Started")
|
|
// }
|
|
|
|
// val timeMessage = """Time.*""".r
|
|
// var count = 0
|
|
|
|
// def onMessage(msg: dom.MessageEvent) = {
|
|
// val s = msg.data.asInstanceOf[String]
|
|
// s match {
|
|
// case timeMessage() =>
|
|
// count += 1
|
|
// if (count % 600 == 0)
|
|
// WorkerGlobal.postMessage("60fps")
|
|
// case _ =>
|
|
// WorkerGlobal.postMessage(s"Received: $s")
|
|
// }
|
|
// }
|
|
// }
|