From 979cc88560dbea0eb6fd0071bff79ffdff21359c Mon Sep 17 00:00:00 2001 From: Rohan Sircar Date: Wed, 30 Dec 2020 13:50:52 +0530 Subject: [PATCH] Added IOUtils --- src/main/scala/outwatchapp/util/IOUtils.scala | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/scala/outwatchapp/util/IOUtils.scala diff --git a/src/main/scala/outwatchapp/util/IOUtils.scala b/src/main/scala/outwatchapp/util/IOUtils.scala new file mode 100644 index 0000000..351ed40 --- /dev/null +++ b/src/main/scala/outwatchapp/util/IOUtils.scala @@ -0,0 +1,21 @@ +package outwatchapp.util + +import cats.arrow.FunctionK +import monix.bio.IO + +object IOUtils { + def toIO[T](task: monix.eval.Task[T]) = + IO.deferAction(implicit s => IO.from(task)) + + def toTask[T](bio: monix.bio.IO[Throwable, T]) = + monix.eval.Task.deferAction(implicit s => bio.to[monix.eval.Task]) + + val ioTaskMapk = + new FunctionK[monix.eval.Task, monix.bio.Task] { + + override def apply[A]( + fa: monix.eval.Task[A] + ): monix.bio.Task[A] = toIO(fa) + + } +}