I am trying to chain together some basic functions using Future
s returned from a slick action and I'm hitting some pretty trivial stumbling blocks.
Both the andThen
and onSuccess
methods require a PartialFunction
passed as a parameter. My understanding is probably quite flawed but after reading about anonymous functions it seems like andThen
needs to know your anonymous function with cater for any Success
or Failure
input.
Given onSuccess
already only caters for the Success
case why does it still need to be a PartialFunction
?
This block of code my indicate the problem I am having:
val db = Database.forConfig("h2mem1")
try {
val f = db.run(setupCommands)
.onSuccess { println(_) }
Await.ready(f, 10.seconds )
}
finally db.close
I get a compile error:
[error] found : Unit => Unit
[error] required: PartialFunction[Unit,?]
[error] .onSuccess { println(_) }