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

3 years ago
  1. // package outwatchapp.util
  2. // import org.scalajs.dom
  3. // import scala.scalajs.js
  4. // import scala.scalajs.js.annotation.JSExport
  5. // import org.scalajs.dom.webworkers.DedicatedWorkerGlobalScope
  6. // import scala.scalajs.js.annotation.JSGlobalScope
  7. // import scala.scalajs.js.annotation.JSExportTopLevel
  8. // // @js.native
  9. // // object WorkerGlobal extends js.GlobalScope {
  10. // // def addEventListener(`type`: String, f: js.Function): Unit = js.native
  11. // // def postMessage(data: js.Any): Unit = js.native
  12. // // }
  13. // @js.native
  14. // @JSGlobalScope
  15. // object WorkerGlobal extends DedicatedWorkerGlobalScope
  16. // @JSExportTopLevel("WorkerMain")
  17. // object WorkerMain {
  18. // @JSExport
  19. // def main(): Unit = {
  20. // // WorkerGlobal.addEventListener("message", onMessage _)
  21. // WorkerGlobal.onmessage = onMessage _
  22. // WorkerGlobal.postMessage(s"Started")
  23. // }
  24. // val timeMessage = """Time.*""".r
  25. // var count = 0
  26. // def onMessage(msg: dom.MessageEvent) = {
  27. // val s = msg.data.asInstanceOf[String]
  28. // s match {
  29. // case timeMessage() =>
  30. // count += 1
  31. // if (count % 600 == 0)
  32. // WorkerGlobal.postMessage("60fps")
  33. // case _ =>
  34. // WorkerGlobal.postMessage(s"Received: $s")
  35. // }
  36. // }
  37. // }