Usage and Installation

See the standard dispatch documentation site for installation and basic usage information: here. It even provides instructions to quickly setup a sbt project directory:

echo 'libraryDependencies += 
  "net.databinder.dispatch" %% "dispatch-core" % "0.11.2"' > build.sbt
sbt console

For many of the examples in this book, I used the amm (ammonite) shell which provides a convenient way to quickly test short programs but does not require a sbt project setup.

Start your amm shell using:

shell>amm
user-pwd@

Then load the dispatch library:

@load.ivy("net.databinder.dispatch" %% "dispatch-core" % "0.11.3") 
@import dispatch._, Defaults._

You can now use dispatch.

The Defaults._ import brings in a scala ExecutionContext. If you want to you your own ExecutionContext, do not import the defaults. It also imports a netty Timer which is used in a few parts of the dispatch library. The imports also pulls in the scala definition of Future so you do not have to include it explicitly.

Using dispatch via the maven coordinates pulls in a < 2.0 version of async-http-client.

Last updated