On Tue, Dec 29, 2009 at 3:36 PM, Ross Mellgren <dri...@gmail.com> wrote:

> On Dec 29, 2009, at 6:28 PM, David Pollak wrote:
>
> On Mon, Dec 28, 2009 at 8:04 AM, Adam Warski <a...@warski.org> wrote:
>
>> Hello,
>>
>> > Yes, the article is out of date now... Lift now makes sure that multiple
>> references to a single snippet in the same request context use the same
>> instance of that snippet.
>> I see, so the rationale behind using dispatch snippets is out of date
>> also. Except that you save one reflection call per page/request. So are
>> there any reasons to use DispatchSnippets now?
>>
>
> Yes.  While they require a tad more code, they are type safe.  My take on
> "by convention" is it's great when you and one or two other people are
> whipping stuff together in a hurry.  As the project moves from rapid
> prototyping to sustainable coding, being explicit with the dispatch makes it
> easier for others to follow the code flow.
>
>
>>
>> > Reflection snippets do not have the same scope as request vars...
>> rather, the snippet is held in a request var.
>> Which essentialy makes them have the same scope as request vars :)
>>
>> By the way, is there a "true" request-scope variable? I saw that there's
>> TransientRequestVar, but it's private in the liftweb package.
>>
>
> There was a particular use case for the TransientRequestVar, so I added it
> and made it available only to the http package.
>
> If you can describe a place where the current RequestVars do not work for
> you, we can talk some more.
>
>
> I've wanted them to cache information that isn't trivial to compute, but
> that I wanted to be regenerated on each AJAX call, for an app with a page
> that could be on-screen and doing AJAX calls for perhaps half an hour or
> more.
>

object Foo extends RequestVar[Box[BigHairyComputation]](Empty)

def myAjaxCallback(): JsCmd = Foo.doWith(computeValueForThisRequest) {
  // do stuff related to doing the Ajax call
}

In the above code, the lifetime of the value calculated by
computeValueForThisRequest is the call to doWith.


> In the end I whipped up controlled cache invalidation and stashed the
> cached information on a StatefulSnippet.
>
> I think they would be a good generally useful thing to have, personally.
>
> -Ross
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>



-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to