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.

23 lines
495 B

  1. package nova.monadic_sfx.util
  2. import monix.eval.Task
  3. import monix.execution.Scheduler
  4. import cats.effect.Effect
  5. import cats.effect.implicits._
  6. object Action {
  7. /**
  8. * Implicitly runs monix task as fire and forget. \
  9. * For use in ScalaFX callbacks.
  10. *
  11. * @param task
  12. * @param s
  13. */
  14. def asyncT[T](task: => Task[T])(implicit s: Scheduler): Unit = {
  15. task.runAsyncAndForget
  16. }
  17. def asyncF[F[_]: Effect, T](cb: => F[T]): Unit =
  18. cb.toIO.unsafeRunAsyncAndForget()
  19. }