General questions should be asked on StackOverflow, not here. This room focuses on development of Binding.scala.
Atry on master
Update scalafmt-core to 2.3.2 Merge pull request #230 from sc… (compare)
I think you can simply use for
/yield
on Vars
.
val prefix = new Var("ForYield")
val source = Vars(1, 2, 3)
val mapped = (for {
sourceElement <- source
i <- Constants((0 until sourceElement): _*)
} yield {
raw"""${prefix.each} $i/$sourceElement"""
})
mapped.watch()
watch()
after you setup all binding expressions.
This kind of expression is pure because it simply create some new BindingSeq
instead of affecting the real world.
However, if I understand your question correctly, you were asking how to change the real world. For Scala.js target, you invoke dom.render
to mount a Binding
or BindingSeq
into a DOM document. For JVM target, you have to create your own SingleMountPoint
or MultiMountPoint
then invoke watch
method on your mount points. In your mount point instance, you will implement some abstract methods to handle data changing events.
protected
. You have to click Show all button to see them in the scaladoc.