Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 12 02:52

    Atry on master

    Update scalafmt-core to 2.3.2 Merge pull request #230 from sc… (compare)

  • Dec 12 02:52
    Atry closed #230
  • Dec 12 02:50
    scala-steward opened #232
  • Dec 12 02:48
    Atry closed #218
  • Dec 12 02:47
    scala-steward opened #231
  • Dec 12 02:47
    scala-steward opened #230
  • Dec 12 02:47
    scala-steward opened #229
  • Dec 12 02:46
    scala-steward opened #228
  • Dec 12 02:46
    scala-steward opened #227
  • Dec 12 02:46
    scala-steward opened #226
  • Dec 07 10:20
    Atry commented #175
  • Dec 07 10:02
    adrobisch commented #175
  • Dec 01 21:52
    Atry commented #175
  • Dec 01 12:39
    adrobisch commented #175
  • Nov 24 09:02
    adrobisch commented #175
  • Nov 24 05:37
    Atry commented #175
  • Nov 24 03:38
    Atry commented #175
  • Nov 23 21:44
    adrobisch commented #175
  • Nov 23 21:44
    adrobisch commented #175
  • Nov 23 21:42
    adrobisch commented #175
Istvan Meszaros
@IstvanM
aham
Jens Egholm
@Jegp
Hey guys
I'm trying to figure out how to use the binding library in Scala (so without the DOM)
I'm not sure whether you recommend this, but it looks pretty slick since all the listener features are in there
Jens Egholm
@Jegp
But I'm getting stuck trying to map the value of a Var. Hope you can help me out :-)
Jens Egholm
@Jegp
So, if I have a Vars element, and I'd like to map the contents
I'd expect it to be something like BindingInstances.bind(Vars(...))(xs => Constant(xs)).. But I can't really get it to react to changes in the Var
Sorry *Vars
杨博 (Yang Bo)
@Atry
@Jegp BindingInstances is an internal data structure. I did not expect it being used by manually written code.
This message was deleted
杨博 (Yang Bo)
@Atry

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()

See https://github.com/ThoughtWorksInc/Binding.scala/blob/master/core/src/test/scala/com/thoughtworks/binding/BindingTest.scala#L211

Note that data-binding is disabled by default. You must call watch() after you setup all binding expressions.
Jens Egholm
@Jegp
@Atry Thanks mate. That makes much more sense. I just skimmed the documentation for something that could map the structure. But this makes much more sense
Hey, and thanks for all the great work. I really like your library as an alternative to all the other reactive frameworks
Jens Egholm
@Jegp
Just one short question. Since your aggregating into constants, is it possible to map further from here on? Or would the changes not be registered in the binding?
Hrm.. I really need to read up on my monads.
So a more specific question could be; if I'd like to extract the sequence to perform some calculation on it reactively, how would you do this within your framework? I assume a for..yield isn't going to cut it because there's no way to escape from the monad scope.
杨博 (Yang Bo)
@Atry
The for/yield expression maps some BindingSeq(including Vars and Constants) to a new BindingSeq. You can perform calculation in the yield block.
杨博 (Yang Bo)
@Atry

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.

Note that these abstract methods are protected. You have to click Show all button to see them in the scaladoc.
@Jegp FYI
杨博 (Yang Bo)
@Atry
Unlike other FRP framework, Binding.scala prevents user from registering event listener for a specific Binding expression. Instead, I encourage you create different types of mount point for different types of underlying system.
SpringBean
@SpringBean
Hello everyone,
SpringBean
@SpringBean
I am new to using Binding.scala and i have just started learning. I really interested and starting to like it. I have some issues where i am stuck, i am not able to figure out about adding a css.file to the main page. I tried all the four ways of adding style/ stylesheet to the page but not able to do it. Second thing is that i have to say fastOptJS, followed by assets and then by assetsTarget everytime i want to compile and run my webpage? How can i write the index.html without the resource generator in the build.sbt. Can you please help me?
杨博 (Yang Bo)
@Atry
@SpringBean I think you can ask your question on Scala.js mail list, because this is not a Binding.scala issue per se.
@SpringBean Did the tutorial of Scala.js resolve your problem?
d065348
@d065348
@Atry thank you. yes i did try the sbt project style , but it did not work. And how do i add a style sheet to this code for example https://thoughtworksinc.github.io/Binding.scala/#0
SpringBean
@SpringBean
@Atry thank you. yes i did try the sbt project style , but it did not work. And how do i add a style sheet to this code for example https://thoughtworksinc.github.io/Binding.scala/#0
SpringBean
@SpringBean
The problem with the sbt set up of project is resolved.
SpringBean
@SpringBean
and also the issue with my css page to the binding.scala is working fine. thank you
杨博 (Yang Bo)
@Atry
@d065348 It's hard for that repository because it use sbt-site. In order to add SASS/SCSS assets, you may want to use sbt-web instead of sbt-site.