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)

Adam Hibble
@Algomancer_twitter
Hey Guys, throwing together a Play + Binding.scala template - https://github.com/Algomancer/Full-Stack-Scala-Starter
I know you guys have one, but I felt this this was a bit more traditional in terms of build set up from my experience. First time playing with binding.scala - let me know what you think.
Gonna be extending it into a SPA example most likely.
I am gonna be writing a few blogs about it, let me know if there are any points you'd like me to hit on. Would love a few quotes about 'Why Binding.scala'
Adam Hibble
@Algomancer_twitter
@Atry Do you mind if I use your Chinese post as a basis to build from? Google translate doesn't do it justice. I run the largest software student society in Australia - post will probably get a fair bit reads. Will link to your original post.
杨博 (Yang Bo)
@Atry
@Algomancer_twitter Of course. Go ahead!
You could also submit your template at http://lightbend.com/activator/template/contribute
Adam Hibble
@Algomancer_twitter
Already done :-) Just waiting for approval.
杨博 (Yang Bo)
@Atry
Cool!
Adam Hibble
@Algomancer_twitter
I have just started exploring it, but it appears to suit my use case pretty nicely. I plan to use it in production for my startup.
If it passes DD
杨博 (Yang Bo)
@Atry
Enjoy it. I will publish the rest Chinese articles about Binding.scala in couple of weeks on InfoQ.
Adam Hibble
@Algomancer_twitter
Regardless, Seems pretty nice - well done. I have yet to dig through the code base. But, what features are currently seeking contribution?
杨博 (Yang Bo)
@Atry
Recently, I myself is porting Binding.scala to JavaFX and FXML. I think it would be really good if you could create an Android port.
You can look into dom.scala, which is the Binding.scala DHTML intergration. It converts XML literals into binding expressions.
Adam Hibble
@Algomancer_twitter
Oh! Not a bad idea, would love to see a todo list / enhancement tag issues / road map for the project. Can't promise anything, but I tend to try and contribute to anything I use a lot. And if I decided to go with Binding.scala
(Y)
Whilst I play with it more. I might make some reusable components. Always nice to have.
What do you think is the best way to manage styles/css?
杨博 (Yang Bo)
@Atry
Yes, reusable components would be great.
I myself use SCSS and Bootstrap in our internal projects
With a sbt-sassify plugin
Adam Hibble
@Algomancer_twitter
I might see how ScalaCSS plays with it. https://github.com/japgolly/scalacss
杨博 (Yang Bo)
@Atry
IIRC @anthonyhoman have some expirences of using Binding.scala with ScalaCSS.
Adam Hibble
@Algomancer_twitter
Brilliant!
Adam Hibble
@Algomancer_twitter
@Atry if you had to give a one liner for the use case of scalajs-react vs Binding.scala - what would it be?
杨博 (Yang Bo)
@Atry
I guess it is "less concepts and more features"
Adam Hibble
@Algomancer
@Atry ha, my Full Stack Scala Starter is trending. https://github.com/trending/scala
杨博 (Yang Bo)
@Atry
Wow
Nikita Gazarov
@raquo
@Atry is it possible to use Bindings.scala without XML literals? I mean, similarly to how JSX's <div /> is equivalent to React.createElement(‘div’), is there an option to write Bindings.scala code using plain function calls instead of XML literals? I looked inside partialTransformXml in dom.scala… Seems like this would be quite complicated, right?
杨博 (Yang Bo)
@Atry
@raquo Yes. You can add a -Xprint:all flag to Scala compiler and see the equivalent plain expressions generated by Binding.scala
Since this question is asked frequently. @raquo Would you mind if you could add it on FAQ page?
Nikita Gazarov
@raquo
Can do, once I figure out how to do this :)
Nikita Gazarov
@raquo
Hrm, unfortunately I don’t think I personally can make use of this output, it’s just too dense :/
e.g.
val element$macro$1: org.scalajs.dom.html.Div = com.thoughtworks.binding.dom.Runtime.TagsAndTags2.div.apply().render;
            partialAppliedMonadic$macro$226.typeClass.map[com.thoughtworks.binding.Binding[com.thoughtworks.binding.Binding.BindingSeq[org.scalajs.dom.raw.Node]], com.thoughtworks.binding.Binding[org.scalajs.dom.html.Div]]({
              implicit def currentTargetReference$macro$5: com.thoughtworks.binding.dom.Runtime.CurrentTargetReference[org.scalajs.dom.html.Div] = new com.thoughtworks.binding.dom.Runtime.CurrentTargetReference[org.scalajs.dom.html.Div](element$macro$1);
              partialAppliedMonadic$macro$226.typeClass.map[com.thoughtworks.binding.Binding[com.thoughtworks.binding.Binding[com.thoughtworks.binding.Binding.Constants[org.scalajs.dom.raw.Text]]], com.thoughtworks.binding.Binding[com.thoughtworks.binding.Binding.BindingSeq[org.scalajs.dom.raw.Node]]]({
                val partialAppliedMonadic$macro$33: com.thoughtworks.binding.Binding.type = com.thoughtworks.binding.Binding;
An earlier compiler stage (namer) produces slightly more readable output, but it does not include the macros transformations.
      $buf.$amp$plus({
        {
          new _root_.scala.xml.Elem(null, "div", _root_.scala.xml.Null, $scope, false, ({
            val $buf = new _root_.scala.xml.NodeBuffer();
            $buf.$amp$plus(new _root_.scala.xml.Text("\n      "));
            $buf.$amp$plus({
              {
                var $md: _root_.scala.xml.MetaData = _root_.scala.xml.Null;
                $md = new _root_.scala.xml.UnprefixedAttribute("onclick", ((event: Event) => contacts.get.$plus$eq(Contact(Var("Yang Bo"), Var("yang.bo@rea-group.com")))), $md);
                new _root_.scala.xml.Elem(null, "button", $md, $scope, false, ({
                  val $buf = new _root_.scala.xml.NodeBuffer();
                  $buf.$amp$plus(new _root_.scala.xml.Text("\n        Add a contact\n      "));
                  $buf
                }: _*))
              }
            });
            $buf.$amp$plus(new _root_.scala.xml.Text("\n    "));
            $buf
          }: _*))
        }
      });
杨博 (Yang Bo)
@Atry
Em... There are two internal phases of macro transfromations. Unfortunately scalac does not separate them.
I guess you need some intermedia expressions between the two internal phases
Nikita Gazarov
@raquo
Oh well. It’d be great if it was possible to build the DOM nodes with an API smilar to scalatags, but implementing this looks beyond my current scala skill level, unfortunately. Still a great project.
杨博 (Yang Bo)
@Atry

In the first internal phase:

@dom def renderInput(source: Var[String]) = {
  <input value={source.bind}/>
}

will be translated to

def renderInput(source: Var[String]) = Binding {
  val myInput = TagsAndTags2.input().render
  val autoBindValue = Binding {
    myInput.value = source.bind
  }
  autoBindValue.bind
  myInput
}
Then, in the second internal phase, the Binding block will be translated to map and flatMap
Nikita Gazarov
@raquo
Hah, I thought ok, maybe let’s try to compile Scala XML with function calls to scala.xml.Elem. Not sure if the macros would pick that up, but that's impossible anyway because scala.xml._ is not compiled for Scala.js
杨博 (Yang Bo)
@Atry
You are right. It's impossible for Scala.js.
Michele Sciabarra
@sciabarra
How can I concatenate 2 BindingSeq[Node] ?
William Ho
@williamho
@dom val concatenated = seq1.bind ++ seq2.bind (or val concatenated = Binding { seq1.bind ++ seq2.bind }) is one way of doing it
Michele Sciabarra
@sciabarra
could super.render().bind ++ <div>...</div> work?
William Ho
@williamho
what does super.render() return in this case? a BindingSeq[Node]?
Michele Sciabarra
@sciabarra
yes
I am basically applying cake pattern to a UI
William Ho
@williamho
I think it would work if you use :+ instead of ++ in this case (appending a single Node element to a seq)