Scala Convert a Variable to Future?

I have a Case Class User and I want to return it as Future(User). But when I do the same I get this error:

No implicits found for parameter executor: ExecutionContext

Can someone help me with the right syntax to convert a non future result to future return type?

>Solution :

If you don’t define an ExecutionContext elsewhere, you can use Scala’s global ExecutionContext with either:

import scala.concurrent.ExecutionContext.Implicits.global

or:

implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global

Leave a Reply