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)

Leonid Turnaev
@glmars

@Atry glad to see a new project https://github.com/GlasslabGames/html.scala :smiley: !
I think, my problem ThoughtWorksInc/Binding.scala#132 can be fixed easy with it. :wink:
Can I ask here, what is reason for inconsistenecy in using NodeBindingSeq and NodeBinding (see https://github.com/GlasslabGames/html.scala#getting-started for example)?:

  <div>
    { tagPicker(tags) }
    <div>{ inputBinding.bind }</div>
  </div>

Can we design @html to use NodeBinding without .bind in interpolation like NodeBindingSeq is?

杨博 (Yang Bo)
@Atry
@glmars I think .bind is acceptable but not necessary for Binding.
Kahli Burke
@kahliburke
I can confirm that with @html, the .bind is allowed but optional
Leonid Turnaev
@glmars
Really!? Is it already worked in current version? And I can rewrite my example as:
<div> { tagPicker(tags) } <div>{ inputBinding }</div> </div> ?
Kahli Burke
@kahliburke
I've added a repo on github that demonstrates some usage patterns with html.scala
Leonid Turnaev
@glmars
Brilliant! :+1:
Henry Ong
@1mdc
Hi, is there a better way to return an empty Binding[BingingSeq[Node]]? I'm doing Constants().map(_ => <!-- empty -->), it is a bit long.
Kahli Burke
@kahliburke
If you use the
https://github.com/thoughtworksinc/bindable.scala library, you could just do <!— —>.bindSeq. In practice I just define a method which does that called empty in a mix in trait and use it.
Leonid Turnaev
@glmars
@1mdc Constants.empty[Node]?
Henry Ong
@1mdc
@glmars it works thanks. @kahliburke that shows me an error value BindingSeq is not a member of org.scalajs.dom.raw.Comment
Kahli Burke
@kahliburke
@1mdc Works for me, did you do import com.thoughtworks.binding.bindable._ ?
@1mdc Also I'm using @html
Henry Ong
@1mdc
@kahliburke I am using BindingScala. I didn't have that import. I will try again when I'm home. thanks for you help. I'm aware that we mentioned @html several times here. sorry I'm new here. what is it? is it a newer version of BindingScala?
Kahli Burke
@kahliburke
@1mdc https://github.com/GlasslabGames/html.scala - It is a new library that builds on top of Binding.scala and provides a new macro that is a replacement for @dom and provides essentially the same functionality for transforming XML tags into dynamically bound DOM in the browser, but much more efficiently in terms of compilation and fastOpt times as well as significantly smaller output size on the client side. It should theoretically provide better performance as well but we haven't benchmarked it quite yet.
@1mdc I can't really think of any reason to use @dom over @html at this point.
@1mdc Also see this example project that uses the new library - https://github.com/kahliburke/html-binding-example
Henry Ong
@1mdc
@kahliburke thank you for very be helpful :)
Kahli Burke
@kahliburke
@1mdc No problem :)
Mustafa Kuscu
@mcku
Would it be ok to use both @dom and @html in the same file, or do they conflict in some sort?
杨博 (Yang Bo)
@Atry
Yes, you can
Henry Ong
@1mdc
I have many files are still in @dom refactoring may take awhile. Will @dom be deprecated anytime soon?
Mustafa Kuscu
@mcku
Has anyone worked on SSR for binding.scala? Maybe you have already heard of scala-graal ( https://github.com/japgolly/scala-graal ), which claims to do a good job in doing SSR. (GraalVM compiles JS and ES6 much more painlessly.) It might be useful to replace react with binding.scala in it.
mattisr
@mattisr

I have a small project written with @dom that I am trying to port into @html. I started by adding dependencies and a small object

import org.lrng.binding.html
object TestHtml {
  @html def get = <div>Div</div>
}

But when I added TestHtml I got the following error:

> fastOptJS
[info] Updating {file:/home/mattias/projects/todo/}js...
[info] Resolving org.eclipse.jetty#jetty-continuation;8.1.16.v20140903 ...
[info] Done updating.
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn] 
[warn]     * com.thoughtworks.binding:futurebinding_sjs0.6_2.12:11.8.1 is selected over 11.7.0
[warn]         +- js:js_sjs0.6_2.12:0.1-SNAPSHOT                     (depends on 11.7.0)
[warn]         +- com.thoughtworks.binding:bindable_sjs0.6_2.12:1.1.0 (depends on 11.7.0)
[warn] 
[warn]     * com.thoughtworks.binding:binding_sjs0.6_2.12:11.8.1 is selected over {11.7.0+144-dfef7165, 11.7.0}
[warn]         +- com.thoughtworks.binding:futurebinding_sjs0.6_2.12:11.8.1 (depends on 11.8.1)
[warn]         +- com.thoughtworks.binding:dom_sjs0.6_2.12:11.8.1    (depends on 11.8.1)
[warn]         +- org.lrng.binding:html_sjs0.6_2.12:1.0.2            (depends on 11.8.1)
[warn]         +- com.thoughtworks.binding:route_sjs0.6_2.12:11.8.1  (depends on 11.8.1)
[warn]         +- com.thoughtworks.binding:bindable_sjs0.6_2.12:1.1.0 (depends on 11.7.0)
[warn]         +- com.thoughtworks.binding:jspromisebinding_sjs0.6_2.12:11.7.0+144-dfef7165 (depends on 11.7.0+144-dfef7165)
[warn] 
[warn] Run 'evicted' to see detailed eviction warnings
[info] Compiling 20 Scala sources to /home/mattias/projects/todo/js/target/classes...
[error] /home/mattias/projects/todo/js/src/main/scala/se/idainfront/binding/components/card/TestHtml.scala:6: exception during macro expansion: 
[error] java.lang.NullPointerException
[error]     at org.lrng.binding.nameBasedXml$Macros$NameBasedXmlTransformer$$anonfun$transformNode$1.applyOrElse(nameBasedXml.scala:109)
[error]     at org.lrng.binding.nameBasedXml$Macros$NameBasedXmlTransformer$$anonfun$transformNode$1.applyOrElse(nameBasedXml.scala:108)
[error]     at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:176)
[error]     at scala.PartialFunction$Lifted.apply(PartialFunction.scala:228)
[error]     at scala.PartialFunction$Lifted.apply(PartialFunction.scala:224)
[error]     at com.thoughtworks.Extractor$PartialFunctionToExtractor$$anon$4.unapply(Extractor.scala:95)
[error]     at org.lrng.binding.nameBasedXml$Macros$NameBasedXmlTransformer$$anonfun$transformLiteral$1.applyOrElse(nameBasedXml.scala:133)
[error]     at org.lrng.binding.nameBasedXml$Macros$NameBasedXmlTransformer$$anonfun$transformLiteral$1.applyOrElse(nameBasedXml.scala:130)
[error]     at org.lrng.binding.nameBasedXml$Macros$NameBasedXmlTransformer.transform(nameBasedXml.scala:142)
[error]     at org.lrng.binding.html$WhiteBoxMacros.transformBody(html.scala:690)
[error]     at org.lrng.binding.nameBasedXml$Macros.macroTransform(nameBasedXml.scala:155)
[error]   @html def get = <div>Div</div>
[error]    ^
[error] one error found
[error] (js/compile:compileIncremental) Compilation failed
[error] Total time: 3 s, completed Oct 1, 2019 5:13:46 PM

I can not get rid of neither the warnings nor the compile error. Any suggestions on how to solve this? I can not find a bindable with dependency to 11.8.1, if that would have solved it.

杨博 (Yang Bo)
@Atry
@mattisr Feel free to create an issue. With a reproduction example is especially welcomed.
Kahli Burke
@kahliburke
@mattisr I get similar evicted warnings, don't think that's your problem. Can you get the html-binding-example to work and compare those dependencies / sbt config with yours?
mattisr
@mattisr
The html-binding-example is really great and I got the dependencies from there.
I have removed all but one of the warnings and I think I have to rebuild bindable with an updated dependency to jspromisebinding to fix the last. I am still quite a rookie on scala/sbt so I have to google how to do it.
If that does not solve my problem I will try to recreate it in something smaller and more public.
Kahli Burke
@kahliburke
@mattisr I have not had to do that, if you upload to a public github repo I could see if it works for me.
mattisr
@mattisr
@kahliburke, you were right. Removing the warnings did not remove the compile error. I will try to create a reproduction that I can upload. Thanks for now.
Zhenhao Li
@Zhen-hao
hi! does Binding.scala support http 2.0?
Kahli Burke
@kahliburke
@Zhen-hao Binding.scala is a client side framework that compiles to JS, so it doesn't interface with HTTP/2. So there's not really an answer to your question but if you're using a server framework that supports delivering JS assets via HTTP/2, there's nothing about Binding.scala that would get in the way of that.
Zhenhao Li
@Zhen-hao
@kahliburke thanks! I am new to web app development. do you mean Binding.scala is agnostic to the backend? can I also do server-side rendering if I want? I assume that would mean running some front end code on the server-side
Kahli Burke
@kahliburke
@Zhen-hao It is agnostic about the backend ... but there is no server side rendering for it, it interacts with the DOM to render elements to the browser dynamically.
Zhenhao Li
@Zhen-hao
thanks a lot, @kahliburke ! I will do more research to figure out what I really need
Zhenhao Li
@Zhen-hao
when will Binding.scala support Scala 2.13?
Henry Ong
@1mdc
Hi, I am updating @dom to @html, it seems @html stop working with scalacss. I receive this error
Error:(31, 92) not enough arguments for method applyNext: (implicit mountPointBuilder: org.lrng.binding.html.NodeBinding.Interpolated.MountPointBuilder[org.scalajs.dom.raw.HTMLAnchorElement,org.lrng.binding.AttributeFactories.properties.className.type,scalacss.internal.StyleA])org.lrng.binding.html.NodeBinding.Interpolated.ElementBuilder[org.scalajs.dom.raw.HTMLAnchorElement].
Unspecified value parameter mountPointBuilder.
                  case Left(link) => <a href={link} className={DropdownStyles.dropdownItem + CommonStyles.isActive(i.isActive.value)}>Dropdown item</a>
mattisr
@mattisr
I tought one had to change className into class when going from @dom to @html.
Henry Ong
@1mdc
@mattisr I tried both className and class, I received same error
Kahli Burke
@kahliburke
@1mdc Does whatever is inside className resolve to a String? Both these work in the example project: <a href="http://www.google.com" className={"myClass"}>Link 1</a> <a href="http://www.google.com" class="myClass">Link 2</a>
@1mdc Or posting a complete example somewhere would help.
@mattisr className should be used for interpolated cases class should be used for a static string.
Henry Ong
@1mdc
@kahliburke sorry for late response. It returns Style object. I convert to string (.htmlClass it is ok now).
Henry Ong
@1mdc
@kahliburke Hi, can I have both @dom and @html in one project. I try to have both but I receive this when compiling.
Error:scala: ## Exception when compiling 25 sources to /.../classes
Method com/thoughtworks/binding/dom$Macros.com$thoughtworks$binding$XmlExtractor$_setter_$com$thoughtworks$binding$XmlExtractor$$ElemWithMetaData_$eq(Lcom/thoughtworks/Extractor;)V is abstract
com.thoughtworks.binding.dom$Macros.com$thoughtworks$binding$XmlExtractor$_setter_$com$thoughtworks$binding$XmlExtractor$$ElemWithMetaData_$eq(dom.scala)
com.thoughtworks.binding.XmlExtractor.$init$(XmlExtractor.scala:151)
com.thoughtworks.binding.dom$Macros.<init>(dom.scala:492)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$5(JavaReflectionRuntimes.scala:44)
scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime(Macros.scala:824)
scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime$(Macros.scala:800)
scala.tools.nsc.Global$$anon$4.macroExpandWithRuntime(Global.scala:482)
scala.tools.nsc.typechecker.Macros$MacroExpander.$anonfun$expand$1(Macros.scala:630)
scala.tools.nsc.Global.withInfoLevel(Global.scala:228)
scala.tools.nsc.typechecker.Macros$MacroExpander.expand(Macros.scala:623)
scala.tools.nsc.typechecker.Macros$MacroExpander.apply(Macros.scala:610)
org.scalamacros.paradise.typechecker.Expanders$Expander.expand$1(Expanders.scala:64)
org.scalamacros.paradise.typechecker.Expanders$Expander.$anonfun$expandAnnotationMacro$2(Expanders.scala:121)
org.scalamacros.paradise.typechecker.Expanders$Expander.onlyIfExpansionAllowed$1(Expanders.scala:58)
org.scalamacros.paradise.typechecker.Expanders$Expander.expandAnnotationMacro(Expanders.scala:121)
org.scalamacros.paradise.typechecker.Expanders$Expander.expandAnnotationMacro$(Expanders.scala:32)
org.scalamacros.paradise.typechecker.Namers$$anon$1.expandAnnotationMacro(Namers.scala:13)
org.scalamacros.paradise.typechecker.Namers$Namer$$anon$2.maybeExpand$1(Namers.scala:377)
org.scalamacros.paradise.typechecker.Namers$Namer$$anon$2.$anonfun$maybeExpand$2(Namers.scala:389)
scala.collection.immutable.Stream.flatMap(Stream.scala:489)
org.scalamacros.paradise.typechecker.Namers$Namer$$anon$2.maybeExpand(Namers.scala:389)
org.scalamacros.paradise.typechecker.Namers$Namer$MaybeExpandeeCompleter.completeImpl(Namers.scala:339)
org.scalamacros.paradise.typechecker.Namers$Namer$MaybeExpandeeCompleter.complete(Namers.scala:329)
org.scalamacros.paradise.typechecker.Namers$Namer$RichType.completeOnlyExpansions(Namers.scala:357)
org.scalamacros.paradise.typechecker.Expanders$Expander.$anonfun$expandMacroAnnotations$2(Expanders.scala:148)
scala.collection.immutable.List.flatMap(List.scala:338)
org.scalamacros.paradise.typechecker.Expanders$Expander.expandMacroAnnotations(Expanders.scala:141)
org.scalamacros.paradise.typechecker.Expanders$Expander.expandMacroAnnotations$(Expanders.scala:128)
org.scalamacros.paradise.typechecker.Expanders$$anon$1.expandMacroAnnotations(Expanders.scala:14)
org.scalamacros.paradise.typechecker.AnalyzerPlugins$AnalyzerPlugin$.pluginsTypeSig(AnalyzerPlugins.scala:21)
scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$1.$anonfun$accumulate$1(AnalyzerPlugins.scala:353)
scala.tools.nsc.typechecker.AnalyzerPlugins.$anonfun$invoke$1(AnalyzerPlugins.scala:325)
scala.tools.nsc.typechecker.AnalyzerPlugins.invoke(AnalyzerPlugins.scala:324)
scala.tools.nsc.typechecker.AnalyzerPlugins.pluginsTypeSig(AnalyzerPlugins.scala:351)
scala.tools.nsc.typechecker.AnalyzerPlugins.pluginsTypeSig$(AnalyzerPlugins.scala:351)
scala.tools.nsc.Global$$anon$4.pluginsTypeSig(Global.scala:482)
scala.tools.nsc.typechecker.Namers$Namer.templateSig(Namers.scala:1208)
scala.tools.ns
Anton Kulaga
@antonkulaga

I am having huge issues with .map method.
Before scala.binding I used monadic html with redux patter, where I have global Var[State] where state is a case class and then just do a lot of:
state.map(s=>s.someField) to pass to my views.
For example I do:

@dom
  def metadataRow(r: Metadata): Binding[Node] = {
    <tr class={statusClass(r.status)}>
      {if(r.parentWorkflowId.isDefined) <td style="border: 0px !important;">
      <i class={if(r.rootWorkflowId.isDefined && r.rootWorkflowId.contains(r.parentWorkflowId.get)) "angle right icon" else "small angle double right icon"}></i>
    </td> else <!--no cell-->}
      <td colspan={if(r.parentWorkflowId.isDefined) "1" else "2"} style={if(r.parentWorkflowId.isDefined) "border: 0px !important;" else ""}>
      <h1>SOME INFO</h1>
      </td>
      <td style={if(r.parentWorkflowId.isDefined) "border: 0px !important;" else ""}>
      <h1>TEST</h1>
      </td>
    </tr>
  }
val metas= allMetadata.map(ms => ms.map(m=>metadataRow(m)))

In Monadic HTML everything went fine but in Binding.scala I constantly get errors like:

[error] /data/sources/cromwell-client/web/js/src/main/scala/group/research/aging/cromwell/web/WorkflowBindingView.scala:21:34: value map is not a member of com.thoughtworks.binding.Binding[Seq[group.research.aging.cromwell.client.Metadata]]
[error]  val metas= allMetadata.map(ms => ms.map(m=>metadataRow(m)))

even though I have

import com.thoughtworks.binding.Binding.BindingInstances.monadSyntax._
import scalaz.std.list._
import scalaz.std._
import scalaz._

in place. The question is how to make binding work for arbitary case class?

Alexis Hernandez
@AlexITC
if I understand correctly, metadataRow(m).bind should fix the issue
Anton Kulaga
@antonkulaga
did not work for me
Kahli Burke
@kahliburke
@antonkulaga Looks like ms is probably a Binding[Seq[..]] or something similar, there are some implicit you can bring in via Scalaz ... i.e. import scalaz.std.list._and then you could use ms.bind.toList.map, if allMetadata is also a collection then you might need something similar as well, if it's a Vars or perhaps Constants then map would work already...
Mustafa Kuscu
@mcku

i remember that confused me some time ago. Something like this worked for me @antonkulaga

  val bindingSeq: Binding[BindingSeq[T]] = Vars(originalSeq: _*)
  val listChildren: BindingSeq[Node] = for (item: T <- bindingSeq.bind) yield {
      itemRenderer(item).bind
  }
  val list: Node = <div>
        {listChildren}
    </div>
  list

BTW, i wish binding.scala's for comprehension supported filtering using if, IIRC it does not