Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
  • Oct 04 11:29
    datalchemist commented #217
  • Oct 04 11:02
    datalchemist commented #217
  • Oct 04 06:58

    Atry on scalafmt

    (compare)

  • Oct 04 06:46

    Atry on master

    Run scalafmt Merge branch 'master' into scal… Merge pull request #221 from Th… (compare)

  • Oct 04 06:46
    Atry closed #221
  • Oct 04 06:46
    Atry synchronize #221
  • Oct 04 06:46

    Atry on scalafmt

    Update scalafmt to 2.0.1 Update sbt to 1.3.2 Merge pull request #215 from sc… and 2 more (compare)

  • Oct 04 06:06
    Atry commented #217
  • Oct 04 05:30
    glmars commented #217
  • Oct 04 05:09
    Atry closed #191
  • Oct 04 05:09

    Atry on master

    Update scalafmt to 2.0.1 Merge pull request #203 from sc… (compare)

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.
SpringBean
@SpringBean
Ok great .Thank you
Carl Porth
@badcarl

Hi there,
I'm looking into using Binding.scala and am unable to render a Seq[String] via for/yield. The Seq is in a nested case class and doesn't need to be a BindingSeq. For example:

import com.thoughtworks.binding.dom

object BindingExample {
  @dom
  def template(strings: Seq[String]) =
    <ul>
      {
        for (s ← strings) yield <li>{ s }</li>
      }
    </ul>
}

I get the error:
BindingExample.scala:8: each must be inside monadic, throwableMonadic, or catchIoMonadic.
Am I missing something?

杨博 (Yang Bo)
@Atry
@badcarl DOM literal is only available in @dom method or BindingSeq's mapping function. However, your inner li is in the normal mapping function that passed to normal Seq.map