Vars could have a method reflect(other: Var[T]) where T is the same as this signal, in order to link their values to another var?, it need more thinking, but I am trying to write a sbt processor that generates wrapper for swing (remember me from the scala list discussion?), and the thing is that for example, all TextComponents have their text signal, a common need is linking texts, this could be done using map, but the text signals are already there (auto generated for all text components suppose) and though you could use overriding to make text signal derivate form another signal, may times its preferred to build the hierarchy and then configure behaviour (setting up bindings, actions etc). I am not sure if the declarative way is the only way to use signals, but sometimes this leads to recursive declarative types when using
val panel = new Panel {...references OtherPanel...}
val otherPanel = new Panel {references panel...}
This can be eluded transforming the val into an object, but this has others drawbacks, for example I have a lib where implicits kick in to pimp up the components providing them some swing building sintax like:
new BorderPanel {
val label = new Label("Label") north this
val changeTextBtn = new Button(Action("Change label") {
label.text = "Other text"
}) center this
}
Because I am using the syntax val something = new ..., implicits can kick in to provide the north and center method, and then return the Component I am using. If the object syntax were to be used, I would have to do something like:
new BorderPanel {
object label extends Label("Label")
label north this
object changeTextBtn extends Button(Action("Change label") {
label.text = "Other text"
})
changeTextBtn center this
}
Which somewhat kill the idea. So in order to elude the cyclic definition problem, sometimes bindings are deferred (and also to keep code clean). Thats why I would need to be able to bind Vars without being able to override them. The idea of reflecting another Var is to attach listeners to it (implicit observing provided in the reflect method) to observe changes in the other Var and reflect it in the calling Var.
Maybe my whole idea sucks and my usecase too, also I don't know if this is a good place to suggest this.
Thanks for your time.