These are chat archives for ThoughtWorksInc/Binding.scala

May 2016
Justin Maat
May 11 2016 19:50
I’m having a bit of trouble understanding Var
is it possible to pass in an Option into Var?
for instance - to indicate an empty sequence of Vars we can do
val thing = Vars.empty[A]
and then dynamically (inside a @dom method) , check for the existance of something inside thing, append to it, etc..
but for a regular Var. How can we pass in a None value (or something to indicate it’s a Var but with no actual value yet)
I’ve tried
val thing = Var(None)
Justin Maat
May 11 2016 19:56
but then when i try to pass it into a function, how can I check for the value’s existence?
example -
val thing = Var(None)
dom.render(document.getElementById(“app”), layout(thing))

def layout(thing: Var[Option[String]]) {
   //access thing here
Justin Maat
May 11 2016 20:01
wait wait, i think my syntax is off. This seems to work if I declare the type first
    val noneThing:Option[String] = None
    val thing = Var(noneThing)
sorry, still learning scala :)