Skip to content

channingwalton/rxlift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rxlift

Join the chat at https://gitter.im/channingwalton/rxlift An experimental reactive library for lift web based on RxScala.

The core idea is to treat UI components as having three components:

  1. a UI component, e.g. an input element
  2. an Observable the UI component observes and maps to the UI, e.g. an Observable[String]
  3. an Observable of values produced by the component, e.g. an Observable[String]

This idea is modeled by RxComponent, which produces RxElements. RxComponents are factories that when given an Observable, return an RxElement that can be rendered in a browser.

This project uses Liftweb to render these RxElements. Have a look at the examples subproject for a demo.

Examples

Clock

The src is here

class Clock extends RxCometActor {

  override def defaultPrefix = Full("clk")

  // An Observable generating a string containing the time every 1 second
  val ticker: Observable[String] = Observable.interval(Duration(1, TimeUnit.SECONDS)).map(_  new Date().toString)

  // using the label component, build an RxElement with the ticker
  val timeLabel: RxElement[String] = Components.label.consume(ticker)

  // send the JsCmds emitted by the label to the actor to send to the UI
  publish(timeLabel)

  // initial render uses the label's ui
  def render = "#time" #> timeLabel.ui
}

Rendered with

<lift:comet type="Clock">
  <p>Current Time: <span id="time">Missing Clock</span></p>
</lift:comet>

About

An experimental rx library for lift web

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published