All Downloads are FREE. Search and download functionalities are using the official Maven repository.

orcus.async.instances.catsEffect.scala Maven / Gradle / Ivy

The newest version!
package orcus.async.instances

import cats.effect.Async
import orcus.async.AsyncHandler

object catsEffect {

  implicit def handleAsync[F[_]](implicit F: Async[F]): AsyncHandler[F] =
    new AsyncHandler[F] {
      def handle[A](callback: AsyncHandler.Callback[A], cancel: => Unit): F[A] =
        F.async[A](cb =>
          F.delay {
            callback(cb)
            Some(F.delay(cancel))
          }
        )
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy