General questions should be asked on StackOverflow, not here. This room focuses on development of Binding.scala.
Atry on master
Update sbt-scalajs, scalajs-com… Merge pull request #310 from sc… (compare)
Atry on master
Update scalatest to 3.2.3 Merge pull request #309 from sc… (compare)
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.
Hi there,
I'm looking into using Binding.scala and am unable to render a Seq[String]
via for
/yield
. The Seq
is in a nested case class and doesn't need to be a BindingSeq
. For example:
import com.thoughtworks.binding.dom
object BindingExample {
@dom
def template(strings: Seq[String]) =
<ul>
{
for (s ← strings) yield <li>{ s }</li>
}
</ul>
}
I get the error:
BindingExample.scala:8: each
must be inside monadic
, throwableMonadic
, or catchIoMonadic
.
Am I missing something?
Hi there, I'm playing around a bit with Binding.scala (mostly the data-binding stuff not the DOM bits), but I'm a bit stuck on how to achieve a rather simple effect.
What I need is to sort of do a fold over all the values in a Binding as they come in and accumulate some state while doing that. (My case is a bit more complicated, but this'll do for a start :))
What I have so far is to have a Var[T] which is set up with the initial accumulator state and to then have a
```scala
(Sorry, this is the full question:)
Hi there, I'm playing around a bit with Binding.scala (mostly the data-binding stuff not the DOM bits), but I'm a bit stuck on how to achieve a rather simple effect.
What I need is to sort of do a fold over all the values in a Binding as they come in and accumulate some state while doing that. (My case is a bit more complicated, but this'll do for a start :smile:)
What I have so far is to have a Var[T] which is set up with the initial accumulator state and to then have a
var externalValue$ = Var[T](...)
var currentState$ = Var[S](...)
val accumulatedState$: Binding[S] = monadic[Binding] {
val nextState: S = (externalValue$.each, currentState$.get) match {
// Choose a new state, S, based on the two values in the pattern match
}
currentState$ := nextState
nextState
}
but seems to be quite cumbersome and I'm sure how/if it can abstracted away into some reusable
building block. (I think I'd have to be able to pass a Monadic block into my abstraction if I want to do
anything other than just a simple (A, S) => S state transition function, perhaps using other variables, etc.
Maybe passing in the Var[T] would be sufficient, but it'd require tupling up the inputs explicitly.)
First of all: Is the above guaranteed to work per the expected semantics of the library? From my little experimentation it seems to, but it's ... inelegant.
:=
operator in a monadic
block.
:=
in a monadic
block.
Binding
is not an event stream.
createSelfRecursiveBinding
, you can have:val event: Var[E] = ...
val state: Binding[S] = createSelfRecursiveBinding(initialState, state => monadic[Binding] {
(event.each, state) match {
// Choose a new state, S, based on the two values in the pattern match
}
})