Seven Things


Lift has built-in Lazy Loading.

Loading
Notice the spinning icon above this paragraph?  That icon indicates that a computation is going on.  The page was rendered back to the browser and when the computation for that part of screen real-estate is complete, the HTML will be delivered to the browser.  And, you can have more than one lazy loaded components on the same page:
Loading
How hard is the code? Here's the display part of the code:
Listing: /lazy.html
      <div data-lift="LazyLoad">
        <span data-lift="LongTime"> I started this computation at
          <span id="start">start</span> and it
          completed at <span id="end">end</span>.
        </span>
      </div>
That's not a lot of markup code. Just mark the block of markup that's going to take a long time to calculate. Lift takes care of the rest. Let's look at the snippet code:
Listing: /net/liftweb/seventhings/snippet/LongTime.scala
/**
 * Do something that takes a long time to do
 */
object LongTime {
  def render = {
    // capture the start time
    val start = now

    // sleep for up to 15 seconds
    Thread.sleep(randomLong(15 seconds))

    // send the result back
    "#start" #> start.toString &
    "#end" #> now.toString
   }
}
Most other frameworks don't have lazy loading as part of the core framework. It's generally very hard to do, but because Lift has excellent comet support, it's easy to "push" content from the server to the browser.

Lift is Copyright 2007-2011 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.