Home

Awesome

LatestEvent.scala

Latest version Scaladoc Scala CI

LatestEvent.scala is a library to track the latest events from HTML DOM objects and other event targets. It can be used with Binding.scala and html.scala for bidirectional data-binding and routing.

Getting Started

def rootView = {
  val inputBinding = html"<input>"
  val value = Binding {
    val input = inputBinding.bind

    // Automatically recaculate whenever `input` is changed
    LatestEvent.change(input).bind
    
    input.value
  }
  html"""<div>
    ${inputBinding.bind}
    Your input value is ${value.bind}
  </div>"""
}

@JSExport def main(): Unit = {
  render(document.body, rootView)
}

It can be also used as an alternative to a routing library. See the todo app for example.

Links