These are chat archives for ThoughtWorksInc/Binding.scala

28th
Dec 2016
jfilali
@jfilali
Dec 28 2016 00:30
@Atry is there a way to map through a Var ? I'm trying to do a simple :
val location = Var[String]("Home")
val isHome : Var[Boolean] = location.map{ v => v=="Home" }
jfilali
@jfilali
Dec 28 2016 01:11
never mind I forget to import Scalaz, I wasn't aware you were dependent of it. You might need to put that in the doc.
杨博 (Yang Bo)
@Atry
Dec 28 2016 01:20
Hi, @jfilali , I would not recommend scalaz syntax for starters. As @sciabarra said, he can be sure to scare off them all.
Especially the map method has very different meanings for Binding, BindingSeq and BindingSeq.get.
jfilali
@jfilali
Dec 28 2016 01:46
@Atry is there a alternative ? I'm trying to apply some basic best practices that is successfully used in others frameworks and this implies limiting the scope of the state I'm propagating in the different components which is really important for complex projects. Actually even after importing, scalaz. and Scalaz. I'm still getting : value map is not a member of com.thoughtworks.binding.Binding.Var[String]
I'm missing something there that I didn't get yet.
杨博 (Yang Bo)
@Atry
Dec 28 2016 01:47
val location = Var[String]("Home")
val isHome = Binding { location.bind == "Home" }
jfilali
@jfilali
Dec 28 2016 01:47
oh of course,
Thank @Yang for your support, you are amazing.
杨博 (Yang Bo)
@Atry
Dec 28 2016 01:49
The .bind is a more powerful alternative to for comprehension
The similar syntax is also available for other monads: https://github.com/ThoughtWorksInc/each
jfilali
@jfilali
Dec 28 2016 02:01
Indeed this is more powerful. The motivation behind this style need to be explain in the doc. I'm pretty sure you will get more traction. Thank you for the link. It is indeed pretty impressive. What a discovery. I though I knew most of the cool things in Scala. Look like this is something I will explore.