Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 20 07:38

    Atry on v11.8.2

    (compare)

  • Nov 20 07:37

    Atry on v11.9.0

    (compare)

  • Nov 20 07:33

    Atry on v11.8.2

    (compare)

  • Nov 20 07:27

    Atry on 219-fix

    (compare)

  • Nov 20 07:27
    Atry closed #219
  • Nov 20 07:27

    Atry on master

    Always update for views and mut… Merge pull request #220 from Th… (compare)

  • Nov 20 07:27
    Atry closed #220
  • Nov 20 07:12
    Atry synchronize #220
  • Nov 20 07:12

    Atry on 219-fix

    Always update for views and mut… (compare)

  • Nov 20 01:33
    Atry reopened #219
  • Nov 20 01:32
    Atry closed #219
  • Oct 09 04:00
    notyy commented #222
  • Oct 09 03:59
    notyy closed #222
  • Oct 09 03:59
    notyy commented #222
  • Oct 08 20:28
    Atry commented #223
  • Oct 08 20:28

    Atry on master

    docs: fix typo Merge pull request #223 from Ja… (compare)

  • Oct 08 20:28
    Atry closed #223
  • Oct 08 20:20
    Jason-Cooke opened #223
  • Oct 07 03:30
    glmars commented #222
  • Oct 06 04:05
    notyy opened #222
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