Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 12 23:59
    scala-steward opened #203
  • Aug 10 08:47
    Atry edited #202
  • Aug 10 08:47

    Atry on Atry-patch-1

    (compare)

  • Aug 10 08:47

    Atry on master

    Keep attribute order Merge pull request #202 from Th… (compare)

  • Aug 10 08:47
    Atry closed #202
  • Aug 10 08:26
    Atry synchronize #202
  • Aug 10 08:26

    Atry on Atry-patch-1

    Keep attribute order (compare)

  • Aug 10 08:04
    Atry synchronize #202
  • Aug 10 08:04

    Atry on Atry-patch-1

    Keep attribute order (compare)

  • Aug 10 07:48
    Atry opened #202
  • Aug 10 07:48

    Atry on Atry-patch-1

    Reverse attributes (compare)

  • Aug 09 23:19

    Atry on Atry-patch-1

    (compare)

  • Aug 09 23:18

    Atry on master

    Add textAttributes extractor Merge pull request #201 from Th… (compare)

  • Aug 09 23:18
    Atry closed #201
  • Aug 09 22:27
    Atry opened #201
  • Aug 09 22:27

    Atry on Atry-patch-1

    Add textAttributes extractor (compare)

  • Aug 09 22:24

    Atry on Atry-patch-1

    (compare)

  • Aug 09 22:24

    Atry on master

    Add the PCData extractor Update XmlExtractor.scala Fix syntax error in Scala 2.11 and 1 more (compare)

  • Aug 09 22:24
    Atry closed #200
  • Aug 09 21:42

    Atry on Atry-patch-1

    Fix syntax error in Scala 2.11 (compare)

Leonid Turnaev
@glmars
We should have an united documentation, because I didn't know about such projects :)
@Atry how do you think should we have something like dom.renderTitle(document, Binding[String]) to render title?
杨博 (Yang Bo)
@Atry
Simply use
Binding {
  document.title = t.bind
}.watch()
杨博 (Yang Bo)
@Atry
@glmars Those projects have not been announced yet. Just some small utilities for my current own needs. The situation might be changed if there are more users and contributors of those projects.
Leonid Turnaev
@glmars
Your implementation of renderTitle is more simple than I expected :smiley:
杨博 (Yang Bo)
@Atry
@/all Sorry to bother you. Just want to let you guys know that I have resigned from ThoughtWorks, though I will keep maintain Binding.scala in my part time.
Since I am back to the job market, you can contact me or give me a job referral if you recognize my expertise in my open source contributions. I am currently seeking for career opportunity in California, especially in the San Francisco bay area or San Diego.
Also it would be great help to me if you retweet or upvote this tweet. https://twitter.com/pop_atry/status/1130654155914145792
Leonid Turnaev
@glmars
All the best!
Wojtek Pituła
@Krever
Its rather standard stuff in US to resign and look for new gig afterward, right? In Europe I typically see people having new place organised before quitting :)
Retweeted of course :)
杨博 (Yang Bo)
@Atry
I quit ThoughtWorks China before finding new employer because my family was moving to US recently. As a L2 visa holder, I must apply for EAD after arriving US.
Mustafa Kuscu
@mcku
Good luck @Atry & keep us posted!
nathanwh71
@nathanwh71

I would like to create a simple static HTML unordered list with the following code

@dom
 def renderSearchForm : Binding[Div] = {
      <div>
       <ul>
         {
           val items= List("Google", "Apple", "GitHub")
           for (item <- items) yield
           {
               <li>{item}</li>
           }
         }
       </ul>
      </div>
  }

However, the "each instructions must be inside a SDE block" error is reported and the code fails to compile. Indeed, what does this error mean? How to eliminate it? The code works if Vars("Google", "Apple", "Github") is used instead.

lxohi
@lxohi
@nathanwh71 This is because for comprehension inside Binding block have different behavior from the normal one. Vars is a way to solve this situation, or you can use Constants if there's no need to update items.
Chris Camel
@ccamel
Good luck @Atry (a little bit late).
Mustafa Kuscu
@mcku
@nathanwh71 there is another workaround, too. import scalaz.std.list._
See the first answer on https://github.com/ThoughtWorksInc/Binding.scala/wiki/FAQ
nathanwh71
@nathanwh71
@lxohi @mcku Thanks for your answer! :)
Stefan Holzmüller
@stefanholzmueller
Is there documentation somewhere about routing? I've seen a few snippets here and there, but I'm missing the big picture. Maybe a large-scale example would also be helpful. I'm wondering how different parts of a webapp would communicate with each other.
I have the feeling Binding.scala has a wonderful minimal API, but the documentation sometimes does not help me (because it compares with React, which I'm not familiar with) and I'm stuck quite often while trying to build something bigger than a single page.
Leonid Turnaev
@glmars
You can use this project https://github.com/ccamel/playground-Binding.scala as an example.
Stefan Holzmüller
@stefanholzmueller
Thanks guys, that looks helpful for understanding routing :)
Mustafa Kuscu
@mcku

You can use this project https://github.com/ccamel/playground-Binding.scala as an example.

I have noticed that some examples in the playground were rendering css and similar into document.head. Very good idea, I am going to test it before using. This could be similar to what react helmet was doing to alter document title etc..

Dylan Arnold
@DylanArnold
Is there a reason Var is invariant when Binding is covariant? I see that some of the other types like Constant and Constants are covariant (possibly overlooked?). I feel like I need this but I don't deal with variance much so could be missing something obvious..
Dylan Arnold
@DylanArnold
I think I might have figured out how to write a better router.
杨博 (Yang Bo)
@Atry
Checkout the source code and mark Var covariant, then the Scala compiler will tell you why it shouldn’t.
Dylan Arnold
@DylanArnold
Will do.
Dylan Arnold
@DylanArnold
Right, I see lots of problems.
Dylan Arnold
@DylanArnold
For anyone interested, the most obvious is that you can't use a var (like Var does) if the type is covariant, this stack overflow question seems to explain why https://stackoverflow.com/questions/8473416/how-to-initialize-covariant-variable
Mustafa Kuscu
@mcku
hi, when foo is private, scalac thinks foo is unused
object Foo {
  private val foo: String = "foo"
  @dom def myFunc = { 
      println(foo)
   }
}
Mustafa Kuscu
@mcku
Code runs as expected but when using tools like scalafix it prunes foo.
杨博 (Yang Bo)
@Atry
I think it should be a bug of Scalac. Would you like to report it to https://github.com/scala/bug ?
Mustafa Kuscu
@mcku
OK..
杨博 (Yang Bo)
@Atry
Feel free to paste a bug link here. I am also curious about how it comes out.
Mustafa Kuscu
@mcku
OK. I've just cross-posted on scala/scala gitter channel..
Mustafa Kuscu
@mcku
After enabling "-Ywarn-macros:after", scalac flag, the unused private warning disappeared for foo both on sbt and scalafix.
杨博 (Yang Bo)
@Atry
:+1:
Mustafa Kuscu
@mcku
However this makes a big set of unused elements appear as warning such as parameter value element$macro$12 in value $anonfun is never used
Anton Kulaga
@antonkulaga
I am migating from monadic-html and having a lot of pain. My question is, why any Var cannot have map method? With Monadic-html it was very common for me to keep State of the application as a large case class (according to Redux pattern) and then do map(_.property) from it to get its field, in Scala Binding I do not see map and I constantly hit "overloaded method value domBindingSeq with alternatives" exception
杨博 (Yang Bo)
@Atry
There is, try import com.thoughtworks.binding.Binding.BindingInstances.monadSyntax._
Anton Kulaga
@antonkulaga
hm, intellij shows me syntax._ as red
Should I import additional library for that?
杨博 (Yang Bo)
@Atry
Sorry, it should be monadSyntax
Anton Kulaga
@antonkulaga
Cool, why is it not mentioned in docs?
after going from either Scala.rx or monadic-html .map is the first thing one tries to do with Var-s
杨博 (Yang Bo)
@Atry
Feel free to create a PR for those methods.
I guess letting object Binding extend MonadSyntax[Binding] will turn those methods avaiable out-of-the-box.
Mustafa Kuscu
@mcku

Here is an example where an element class list is appended transition hiddenand mounted before the animation related jquery is applied to the element:

def animatedSingleMountPoint(elem: Binding[Node]) = new SingleMountPoint[Node](elem) {

      override def set(c: Node): Unit = { 
          val classAttr: Attr = c.attributes.getNamedItem("class")

          classAttr.value = classAttr.textContent + " transition hidden"

          js.timers.setTimeout(0) {
            import facades.SemanticUI.jq2semantic
            SemanticJQueryStatic(c).transition(js.Dynamic.literal(animation = "slide down"))
          }
       }        
   }

@dom def showContentAnimated(content: Binding[Node]) = { 
      animatedSingleMountPoint(content).bind
      content.bind    
}

jq2semantic is the facade pertaining to jquery and semantic ui jquery module. showContentAnimated(yourContentBinding).bindwill render an animated content that will slide down.
js.timeout might be considered ugly but without the js.timeout it won't find the element as the element won't be mounted yet. I don't know a better solution to the animations problem yet..

Recently i was looking at @lxohi's ant-design-binding project and saw a similar usage there, but it was managing animations at a lower level. Maybe this way we can generalize more by utilizing existing frameworks with built in simple animation support.
杨博 (Yang Bo)
@Atry
I think requireAnimationFrame is the better API than timer
Mustafa Kuscu
@mcku
@Atry thank you for the idea. i understand that r.A.F. has significant benefits. so it is good to replace the timer with it and it works fine:
def animatedSingleMountPoint(elem: Node) = new SingleMountPoint[Node](Binding(elem)) {
     def init(timestamp: Double) = { 
         ...
         SemanticJQueryStatic(elem).transition(...)
     }

     override def set(c: Node): Unit = { 
         ....
         window.requestAnimationFrame(init)
     }        
}