Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 27 06:08

    Atry on master

    Update scalatest to 3.1.1 Merge pull request #260 from sc… (compare)

  • Feb 27 06:08
    Atry closed #260
  • Feb 26 21:55
    Atry closed #259
  • Feb 26 21:55
    Atry closed #258
  • Feb 26 21:55

    Atry on master

    Update scalafmt-core to 2.4.2 Merge pull request #261 from sc… (compare)

  • Feb 26 21:55
    Atry closed #261
  • Feb 26 21:39
    Atry commented #262
  • Feb 24 13:33
    nemccarthy opened #262
  • Feb 23 02:36
    scala-steward opened #261
  • Feb 21 04:46
    scala-steward opened #260
  • Feb 16 04:27
    scala-steward opened #259
  • Feb 15 09:45
    scala-steward opened #258
  • Feb 10 22:17
    scala-steward opened #257
  • Feb 03 23:27
    scala-steward opened #256
  • Jan 24 19:12
    scala-steward opened #255
  • Jan 23 20:20
    scala-steward opened #254
  • Jan 16 18:58
    scala-steward opened #253
  • Jan 07 16:20
    Atry closed #252
  • Jan 07 16:20
    Atry commented #252
  • Jan 07 09:27
    jilen opened #252
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

mattisr
@mattisr

I would like beeing able to include 3d party webcomponents. I am using the @html variant of Binding.scala and as I understand the info in https://github.com/GlasslabGames/nameBasedXml.scala#xml-library-vendors it should be possible. I have read that I should define my own implicit classes to extend with new tags and I have seen the private object org.lrng.binding.ElementFactories, but I do not understand what I actually should do.
(I have already tried to use the tag prefix 'data:', but I guess it only works with the @dom variant of Binding.scala)

Can someone please provide me with some directions or even better a working example, it would be really cool to be able to use existing webcomponents in a typesafe way.

mattisr
@mattisr
@mattisr Here is my attempt to use 'data:' prefix: https://github.com/mattisr/html-binding-example/tree/using_webcomponents
mattisr
@mattisr
@1mdc Have you found out how to mix @dom and @html annotations in one project? I tried here but failed.
mattisr
@mattisr
I am studying this file and hope I find out how to add support for externally defined webcomponents, am I on the right track?
Yang, Bo
@Atry
I don't think you need read that file
The README is a little out of time. You can check out the new proposal here: https://docs.scala-lang.org/sips/name-based-xml.html
Just create some builders similar to the Motivating Examples
mattisr
@mattisr
Great, thanks.
Henry Ong
@1mdc
@mattisr no, I ended up refactoring all at once
nova
@nova999
Hello, I'm trying out binding.scala with html.scala on scala 2.13 . The example in the readme section of html.scala are giving errors like
[error] found : scala.xml.Elem [error] required: org.lrng.binding.html.NodeBinding[org.scalajs.dom.raw.HTMLInputElement] [error] (which expands to) com.thoughtworks.binding.Binding[org.scalajs.dom.raw.HTMLInputElement]{val value: org.scalajs.dom.raw.HTMLInputElement} [error] val inputBinding: NodeBinding[HTMLInputElement] = <input type="text"/>
nova
@nova999
'
Dylan Arnold
@DylanArnold
Has anyone been able to get scalafmt to work correctly when you have multiple nested elements and then a code block? I get really ugly formatting, see this example: https://gist.github.com/DylanArnold/d75c8ad321239decb26b841971f1a74e
Dylan Arnold
@DylanArnold
I'll ask in scalafmt too.