I've been working with 2.5-M2 and noticed an interesting thing with idMemoize and RequestVars.
I have a snippet like this:
object Count extends RequestVar[Int](0)
object Memoize {
def incrementCount = {
val count = Count.is
Count.set(count + 1)
}
def render = {
"div" #> SHtml.idMemoize(in => {
"@count *" #> Text(Count.is.toString) &
"@refresh [onclick]" #> SHtml.ajaxInvoke(() => {
incrementCount
in.setHtml()
})
})
}
}
The first time refresh is clicked a 1 is displayed in count, as you would expect. However, the second time it's clicked a 1 is still displayed, not what you would expect. The third time it displays a 2. This doesn't happen in 2.5-M1. Maybe I'm missing something ...
My use case for doing this type of thing is putting the IdMemoizeTransform into a RequestVar so I can share it across Snippets.
Here is a sample project to run the example:
https://github.com/kaiserpelagic/lift-example