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)

Philip Stutz
@pstutz
i'm currently struggling with debugging code that is modified by the @dom macro and get errors like this one:
"each instructions must be inside a SDE block"
i encounter this error often in simple examples that are superficially like the table on the example page, but i don't know how to figure out what's wrong. do you have suggestions?
杨博 (Yang Bo)
@Atry
Which version are you using?
Philip Stutz
@pstutz
8.0.0
杨博 (Yang Bo)
@Atry
Have you put your .bind expression into @dom methods?
Philip Stutz
@pstutz
yes.
杨博 (Yang Bo)
@Atry
Is it in a closure?
Philip Stutz
@pstutz
happens in blocks like this:
"""
@dom def tableOrNothing: Binding[Node] = {
val categoryOption: Option[Category] = selectedCategory.bind
val categoryTableOption = categoryOption.map(new CategoryView().table)
val tableOption: Option[Node] = categoryTableOption.map(
.bind)
tableOption.getOrElse(<div/>)
}
"""
杨博 (Yang Bo)
@Atry
You created a closure for categoryTableOption.map
Philip Stutz
@pstutz
how do i enable the macro in a closure?
杨博 (Yang Bo)
@Atry
You can create nested @doms in any closure.
Then, val tableOption: Option[Node] should be changed to val tableOption: Option[Binding[Node]]
@dom val i: Binding[Int] = 1
val myOption: Option[Binding[Int]] = Some(10).map { v => Binding { i.bind + v }} // Result is: Some(Binding(11))
Binding is like @dom, with some minor differences.
Philip Stutz
@pstutz
thank you very much.
杨博 (Yang Bo)
@Atry
Have fun with Binding.scala! :smile:
Philip Stutz
@pstutz
using Binding { ... } blocks to enable the macros works well, thanks. :D
sorry for the newbie question: how do i create an empty node binding? Binding { <div/> } is ugly, but i cannot leave it empty or put in unit.
杨博 (Yang Bo)
@Atry
Try this: Binding { <!-- Render nothing because ... --> }
Philip Stutz
@pstutz
thanks a lot. would you appreciate it if i sent pull requests with documentation for these features? they're really useful and to the best of my knowledge they're not documented yet.
杨博 (Yang Bo)
@Atry
Yes, please!
Philip Stutz
@pstutz
i guess there are more backend newbs who struggle with just putting an html comment in. :P
杨博 (Yang Bo)
@Atry
Could you create a FAQ page on wiki? I will create a link to there.
Philip Stutz
@pstutz
wikis don't have good support for pull requests. forked and put it here: https://github.com/pstutz/Binding.scala/wiki/FAQ
feel free to just copy & paste.
杨博 (Yang Bo)
@Atry
I have merge your changes. Thank you @pstutz !
Ólafur Páll Geirsson
@olafurpg
Hi, just want to say thank you @Atry, this library is amazing. It took a while to wrap my head around when/where to use .bind but once I got past that it was very straightforward to write a frontend with routing and other cool stuff.
The todo mvc was a great resource for picking up things.
杨博 (Yang Bo)
@Atry
@olafurpg Enjoy it :smile:
Chris Camel
@ccamel
Hi every one. I'm pretty new to the Binding.scala framework. I succeeded in using it to some extent, but now, for whatever reason it does not work at all. When compiling the scala code (sbt fastOptJS), the compiler halts with a weird exception:
[error] (compile:compileIncremental) java.lang.AssertionError: assertion failed: 
[error]   object Binding
[error]      while compiling: /home/ccm/Sources/mine/crucibuild-gui3/src/main/scala/org/main.scala
[error]         during phase: erasure
[error]      library version: version 2.11.8
[error]     compiler version: version 2.11.8
I really don't understand what is going on, and any help would be welcome.
When I remove the @dom annoation, everything compiles correctly.
杨博 (Yang Bo)
@Atry
Looks like a bug in Scala compiler. Could you reproduce it
Ólafur Páll Geirsson
@olafurpg
Not necessarily a bug in the Scala compiler, could be an invalid tree created by the dom macro. The compiler error could be more more friendly however.
Chris Camel
@ccamel
I suspect also a bug in the @dom macro.
To reproduce, i created a publid git repo:
> git clone https://bitbucket.org/ccamel/scala-binding-issue.git 
> sbt
> > fastOptJS
versions:
sbt: 0.13.1
scala: 2.11.8
scalajs: 0.9.1
bindings: 'latest.release'
杨博 (Yang Bo)
@Atry
@chris-tek Please remove the libraryDependency to "com.thoughtworks.binding" %%% "core" % "latest.release", as this library has been removed since Binding.scala 8.0.0
Chris Camel
@ccamel
@Atry Yesss ! It works ! Yeepee ! Many Many thanks :smile:
杨博 (Yang Bo)
@Atry
@chris-tek A hint: you can specify a version number instead of latest.releasein order to avoid accidental version upgrading.
William Ho
@williamho
Is there a way to use a tag that doesn't exist in scalatags? (kind of like how data: can be used for attributes) Basically I want to create a <dialog> element but there's no such tag.
杨博 (Yang Bo)
@Atry
Try document.createElement
William Ho
@williamho
yeah that's what I ended up doing. was just wondering if there was a way to do it with HTML literal, but I guess not
杨博 (Yang Bo)
@Atry
Not yet. I hope we could add custom xmlns support in the future
Chris Camel
@ccamel
@Atry Yes. It would be a nice feature. I have the same problem with "svg" element.
杨博 (Yang Bo)
@Atry
@chris-tek @williamho Here is a workaround: since currently all tags are rendered as com.thoughtworks.binding.dom.Runtime.TagsAndTags2.$labelName().render https://github.com/ThoughtWorksInc/Binding.scala/blob/9.0.x/dom/src/main/scala/com/thoughtworks/binding/dom.scala#L317 , you can provide an implicit view to TagsAndTags2.type.
implicit final class MyTags(_: TagsAndTags2.type) {
  final case class dialog() {
    def render = {
      document.createElement("dialog")
    }
  }
}
Chris Camel
@ccamel

@Atry Yes, it works ! :+1:
I have still an issue, with custom attributes. Is there a way to express this kind of element:

<use xlink:href="#stroked-cancel"></use>

Note the namespace xlink. The following code does not work:

<use data:xlink:href="#stroked-cancel"></use>
杨博 (Yang Bo)
@Atry
I guess you have to create a xlink property in your class for user element
in the the class that your render methed returns
William Ho
@williamho
cool, I'll try the implicit class later. thanks!
Chris Camel
@ccamel
@Atry I'm not sure I understand. You propose to do something like this:
    final case class use() {
      def render = {
        val element = document.createElement("use")
        element.setAttribute("xlink:href", "#stroked-cancel")
      }
    }