score:0

Accepted answer

well the error basically says that lift can't render

com.twitter.util.future[scalaz.validationnel[string,net.liftweb.http.liftresponse]]

(at compile time.) to solve your problem you probably have to decompose your task. first, find out whether lift can render that "validation" thing:

scalaz.validationnel[string,net.liftweb.http.liftresponse]

if it can't then you'll have to teach lift. so you should create an implicit (visible in the scope) with the type signature validationnel[***] => liftresponse. you can probably just convert this to a box, which has a default way of rendering an error (empty box). or you should write your custom code with "if" and 2 branches, one of which is badresponse and another is the success.

another task would be to check whether lift knows hot to render twitter-s future-s. again, you should create a simple data and try to render it out. like future(okresponse()). in order to teach lift about twitter futures you probably would have to implement an implicit again, with the type signature future[t] => liftresponse. that would probably involve a restcontinuation.

score:0

lift now supports async calls with lafuture. here a sample code:

case "delay" :: nil get _ =>
  lafuture.build({
    thread.sleep(2000)
    <b>hello</b>
})

when you run it and access /delay the request will be executed asynchronously at the server.

of course you will not explicitly call to thread.sleep in your real code, this is only for sample purposes.

the complete project for this sample code is found at https://github.com/dpp/lift_30_samples (with a couple of quick fixes here -> https://github.com/listatree/lift_30_samples).

now regarding the transformations you are trying to perform, i would recommend you to use lift's canbind functionality. here a sample about them: https://github.com/fmpwizard/lift_starter_2.4/tree/la-futures-2 that also uses lift's lafuture but make some transformations with it (by the way those transformations are taking in place automatically as for lift 2.6 so use this canbind sample just as a reference for the transformations in question here)

lift also supports lafuture for snippet rendering a quick sample for that is:

def render = "*" #> lafuture.build({
  thread.sleep(2000)
  <div>hello</div>
})

this will use the lift's comet infrastructure to make the snippet rendering asynchronous.

also you can make use of parallel snippets that requires you to include the argument parallel to true as in:

<div data-lift="helloworld.howdy?parallel=true">the time is: <span id="time"></span</div>

the parallel snippets works nicely but they consume precious threads, lift still needs a solution for real non-blocking snippet rendering at server side. let's see what's coming for lift 3.


Related Query

More Query from same tag