Skip to content

Instantly share code, notes, and snippets.

@stanch
Created June 17, 2014 23:26
Show Gist options
  • Save stanch/13430a4657798f3a43b3 to your computer and use it in GitHub Desktop.
Save stanch/13430a4657798f3a43b3 to your computer and use it in GitHub Desktop.
val rx1 = Var(1)
val rx2 = Var(2)
val rx3 = Rx { rx1() + rx2() }
// ...
val style = TextSize.large + padding(all = 16 dp)
def rxText(rx: Rx[Int]) = rx.map(_.toString).map(text)
def rxClick(rx: Var[Int]) = On.click(Ui {
rx() = rx() + 1
})
val view = l[VerticalLinearLayout](
w[Button] <~ style <~ rxText(rx1) <~ rxClick(rx1),
w[Button] <~ style <~ rxText(rx2) <~ rxClick(rx2),
w[Button] <~ style <~ rxText(rx3)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment