title: Completing a Promise[T] with Async in Scala and Play2
body: <p>I am trying to complete a Promise[String] for my Action. So far I've read the Play's documentation on asynchronous programming at <a href="http://www.playframework.com/documentation/2.0/ScalaAsync" rel="nofollow">http://www.playframework.com/documentation/2.0/ScalaAsync</a> but there's something I am not getting - or the docs are wrong :) </p>
  
  <p>Here's an outline of my code. My intention is to return a Promise[String] and complete that in my Action. The content of the Promise may come from different places, so I would like to be able to return a Promise[String] to have the Action handler simple. </p>
  
  <pre><code>def getJson = Action { request =&gt;
    val promiseOfJson = models.item.getJson
    Async {
      promiseOfJson.map(json =&gt; Ok(json))
    }   
  }
  
  def models.item.getJson: Promise[String] = {
    val resultPromise = promise[String]
    future {
       ...
       resultPromise success "Foo"
    }
  
    resultPromise
  }
  </code></pre>
  
  <p>Looking at Play's documentation and at "AsyncResult" I think I am doing the same thing, no? </p>
  
  <p>Problem is that I get a compilation error inside my Async {} block:</p>
  
  <blockquote>
    <p>value map is not a member of scala.concurrent.Promise[String]</p>
  </blockquote>