zio-interop-monix


License

License

GroupId

GroupId

dev.zio
ArtifactId

ArtifactId

zio-interop-monix_sjs0.6_2.11
Last Version

Last Version

3.2.2.0-RC2
Release Date

Release Date

Type

Type

jar
Description

Description

zio-interop-monix
zio-interop-monix
Project URL

Project URL

https://zio.dev
Project Organization

Project Organization

dev.zio
Source Code Management

Source Code Management

https://github.com/zio/interop-monix/

Download zio-interop-monix_sjs0.6_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/dev.zio/zio-interop-monix_sjs0.6_2.11/ -->
<dependency>
    <groupId>dev.zio</groupId>
    <artifactId>zio-interop-monix_sjs0.6_2.11</artifactId>
    <version>3.2.2.0-RC2</version>
</dependency>
// https://jarcasting.com/artifacts/dev.zio/zio-interop-monix_sjs0.6_2.11/
implementation 'dev.zio:zio-interop-monix_sjs0.6_2.11:3.2.2.0-RC2'
// https://jarcasting.com/artifacts/dev.zio/zio-interop-monix_sjs0.6_2.11/
implementation ("dev.zio:zio-interop-monix_sjs0.6_2.11:3.2.2.0-RC2")
'dev.zio:zio-interop-monix_sjs0.6_2.11:jar:3.2.2.0-RC2'
<dependency org="dev.zio" name="zio-interop-monix_sjs0.6_2.11" rev="3.2.2.0-RC2">
  <artifact name="zio-interop-monix_sjs0.6_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='dev.zio', module='zio-interop-monix_sjs0.6_2.11', version='3.2.2.0-RC2')
)
libraryDependencies += "dev.zio" % "zio-interop-monix_sjs0.6_2.11" % "3.2.2.0-RC2"
[dev.zio/zio-interop-monix_sjs0.6_2.11 "3.2.2.0-RC2"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
org.scala-js : scalajs-library_2.11 jar 0.6.33
io.monix : monix_sjs0.6_2.11 jar 3.2.2
dev.zio : zio_sjs0.6_2.11 jar 1.0.0-RC18-2
dev.zio : zio-test_sjs0.6_2.11 jar 1.0.0-RC18-2

provided (1)

Group / Artifact Type Version
com.github.ghik : silencer-lib_2.11 jar 1.4.2

test (4)

Group / Artifact Type Version
org.scala-js : scalajs-test-bridge_2.11 jar 0.6.33
org.scalacheck : scalacheck_2.11 jar 1.14.3
dev.zio : zio-test-sbt_2.11 jar 1.0.0-RC21-2
org.scala-js : scalajs-java-time_sjs0.6_2.11 jar 1.0.0

Project Modules

There are no modules declared in this project.

Interop Monix

CircleCI Releases Snapshots

Task conversions

Interop layer provides the following conversions:

  • from Task[A] to UIO[Task[A]]
  • from Task[A] to Task[A]

To convert an IO value to Task, use the following method:

def toTask: UIO[eval.Task[A]]

To perform conversion in other direction, use the following extension method available on IO companion object:

def fromTask[A](task: eval.Task[A])(implicit scheduler: Scheduler): Task[A]

Note that in order to convert the Task to an IO, an appropriate Scheduler needs to be available.

Example

import monix.eval.Task
import monix.execution.Scheduler.Implicits.global
import zio.{ IO, DefaultRuntime }
import zio.interop.monix._

object UnsafeExample extends DefaultRuntime {
  def main(args: Array[String]): Unit = {
    val io1 = IO.succeed(10)
    val t1  = unsafeRun(io1.toTask)

    t1.runToFuture.foreach(r => println(s"IO to task result is $r"))

    val t2  = Task(10)
    val io2 = IO.fromTask(t2).map(r => s"Task to IO result is $r")

    println(unsafeRun(io2))
  }
}

Coeval conversions

To convert an IO value to Coeval, use the following method:

def toCoeval: UIO[eval.Coeval[A]]

To perform conversion in other direction, use the following extension method available on IO companion object:

def fromCoeval[A](coeval: eval.Coeval[A]): Task[A]

Example

import monix.eval.Coeval
import zio.{ IO, DefaultRuntime }
import zio.interop.monix._

object UnsafeExample extends DefaultRuntime {
  def main(args: Array[String]): Unit = {
    val io1 = IO.succeed(10)
    val c1  = unsafeRun(io1.toCoeval) 

    println(s"IO to coeval result is ${c1.value}")

    val c2  = Coeval(10)
    val io2 = IO.fromCoeval(c2).map(r => s"Coeval to IO result is $r")

    println(unsafeRun(io2))
  }
}
dev.zio

ZIO

ZIO — Real World Functional Programming

Versions

Version
3.2.2.0-RC2
3.2.2.0-RC1
3.2.1.0-RC2
3.2.1.0-RC1
3.1.0.0-RC2
3.1.0.0-RC1
3.0.0.0-RC9
3.0.0.0-RC8
3.0.0.0-RC7
3.0.0.0-RC6
3.0.0.0-RC5-4
3.0.0.0-RC5-3
3.0.0.0-RC4
3.0.0.0-RC3
3.0.0.0-RC2
1.0.0-RC8-12
1.0.0-RC8-11
1.0.0-RC8-10
1.0.0-RC8-9
1.0.0-RC8-8
1.0.0-RC8-7
1.0.0-RC8-6
1.0.0-RC8-5
1.0.0-RC8-4
1.0.0-RC8
1.0.0-RC6