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.
|
|
package nova.monadic_sfx.ui
import scala.concurrent.duration._
import io.odin.Logger import monix.bio.Task import nova.monadic_sfx.executors.Schedulers import nova.monadic_sfx.ui.DefaultUI import scalafx.application.JFXApp import scalafx.application.JFXApp.PrimaryStage
class MyFxApp(val schedulers: Schedulers)(implicit logger: Logger[Task]) {
private lazy val internal = new JFXApp { stage = new PrimaryStage { scene = DefaultUI.scene } }
// def stage = Task(internal.stage)
// def stage_=(stage: PrimaryStage) = Task(internal.stage = stage)
// def useInternal[T](f: JFXApp => Task[T]): Task[T] =
// for {
// _ <- logger.debug("Request for using internal value")
// res <- f(internal).executeOn(schedulers.fx)
// _ <- logger.debug(s"Result was ${res.toString()}")
// } yield (res)
def init(stage: => PrimaryStage, delay: FiniteDuration = 200.millis) = for { _ <- logger.info("Starting FX App") fib <- Task(internal.main(Array.empty)).start _ <- Task.sleep(200.millis) _ <- Task(internal.stage = stage) .executeOn(schedulers.fx) .delayExecution(delay) } yield (this, fib)
}
|