rtimush / scalatags-rx   0.5.0

GitHub

Integration between scalatags and scala.rx

Scala versions: 2.13 2.12
Scala.js versions: 1.x

scalatags-rx Build Status

ScalaTags-Rx is a small integration layer between ScalaTags and Scala.Rx. It provides a set of type class instances for Rx[T] values that allows you to use them directly in a ScalaTags DSL with changes automatically propagated to the resulting DOM:

import scalatags.rx.all._

object Example extends JSApp {

  val c = Var("blue")
  val text = Rx(s"It is a ${c()} text!")

  def toggle(): Unit = {
    c() = if (c.now == "blue") "green" else "blue"
  }

  override def main(): Unit = {
    document.body.appendChild(
      div(
        color := c, onclick := toggle _,
        text
      ).render
    )
  }

}

Getting Started

ScalaTags-Rx is hosted on Maven Central, to get started, simply add the following to your build.sbt:

libraryDependencies += "com.timushev" %%% "scalatags-rx" % "0.4.0"

For the latest development version use:

resolvers += Resolver.sonatypeRepo("snapshots")

libraryDependencies += "com.timushev" %%% "scalatags-rx" % "0.4.1-SNAPSHOT"