scalasbtscala-2.10scala-dispatch

Error dispatch-nio is not found


I m trying out the example given at http://dispatch-classic.databinder.net/Choose+an+Executor.html for dispatch-nio: Example given:

import dispatch._
val h = new nio.Http
val f = h(url("http://www.scala-lang.org/") as_str)

My code:

  import dispatch._
  val h = new nio.Http
  var host = "http://www.scala-lang.org";
    val f: Future[String] = h(url("http://www.scala-lang.org/") as_str)
    f.apply();

But it doesn't recognize nio and as_str keywords. Could anyone please suggest what would be the problem?


Solution

  • I'm not sure of your version but I've got it to work with 0.8.1, the namespace looks like it's changed from the documentation.

    In build.sbt:

    libraryDependencies += "net.databinder" %% "dispatch-nio_2.10.2" % "0.8.1"

    In code:

    import dispatch.classic._
    
    val h = new nio.Http
    var host = "http://www.scala-lang.org";
    val f = h(url("http://www.scala-lang.org/") as_str)
    f.apply()
    

    You may need to substitute the 2.10.2 in the library dependency with your scala version number.