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)

杨博 (Yang Bo)
@Atry
Never mind
Moritz Bust
@Busti
I recently had a chat with the folks over at scala/contributors and became aware of the fact that xml mode will be faded out with scala 3.
What will happen with binding.scala when that happens?
杨博 (Yang Bo)
@Atry
@Busti Where is the link of the chat
Moritz Bust
@Busti
@Atry Seems like the discussion is still going on at https://gitter.im/scala/contributors
Moritz Bust
@Busti
Does binding.scala use a compiler plugin to parse the contend of @dom methods differently?
Or does it rely on xml literals?
杨博 (Yang Bo)
@Atry
No. Instead, Binding.scala hacks the AST generated by the Scala parser.
Moritz Bust
@Busti
Does that mean that an attr without a value like <foo bar></foo> is possible?
杨博 (Yang Bo)
@Atry
Are you talking about Scala 3 or the current version of Binding.scala?
Moritz Bust
@Busti
The current version of binding.scala . Since scala xml literals are not sgml literals, the above is not valid xml.
杨博 (Yang Bo)
@Atry
I don't think Scala 2 parser accepts <foo bar></foo>
Moritz Bust
@Busti
I recently tried it on https://astexplorer.net/ and it failed without generating ast for the "malformed" literal.
杨博 (Yang Bo)
@Atry
🤷
Moritz Bust
@Busti
Thanks a lot for your answers :)
杨博 (Yang Bo)
@Atry

@/all Hello, Binding.scala users and contributors,

There is a discussion about the feature of XML literals in Scala 3, in which you guys may be interested.

杨博 (Yang Bo)
@Atry
@/all You may also want to have a look at the proposal of name-based XML literal at https://contributors.scala-lang.org/t/pre-sip-name-based-xml-literals/2175
Leonid Turnaev
@glmars
Hi @Atry, could you publish new release with ThoughtWorksInc/Binding.scala#90 and ThoughtWorksInc/Binding.scala#104 included?
杨博 (Yang Bo)
@Atry
Sure
Leonid Turnaev
@glmars
Thanks ;)
杨博 (Yang Bo)
@Atry
@glmars It seems that CI is broken due to absence of Oracle JDK
Leonid Turnaev
@glmars
Yeah I saw. Looks like your latest commit have fixed this! :+1:
Leonid Turnaev
@glmars
You have done a big code cleaning yesterday! :thumbsup: :star2: :smile:
Leonid Turnaev
@glmars
Binding.scala 11.2.0 already in Maven Central! :tada:
Wojtek Pituła
@Krever
Hey, sorry for asking here, but my question probably doesn't fit stack overflow either. Is there any up-to-date example/starter for binding.scala with scalajs-bundler/webpack? Or should I just try to assemble it from scratch?
Leonid Turnaev
@glmars
Unfortunately, I don't know such examples, but this should be easy! There is no something special with scalajs-bundler and Binding.scala. Binding.scala is regular Scala.js library.
Wojtek Pituła
@Krever
I see now, I got one working byt adjusting slinky starter. It was easy, but having something out of the box would be nice from increasing adoption perspective. Nevertheless I find Binding.scala an extremely nice project :)
Btw should I consider some state manager like diode/redux or this is not needed with Binding.scala ?
Leonid Turnaev
@glmars
Binding.scala works well without it
Pascal Mengelt
@pme123
@Krever I wrote once a blog about Binding.scala with Redux - see https://pme123.github.io/scala-adapters/development/binding-scala-redux/
Wojtek Pituła
@Krever
@pme123 thanks, will checki it out
Wojtek Pituła
@Krever
There is no explicit map or flatMap for Bindings, but one can use scalaz for that, right?
Wojtek Pituła
@Krever

thanks. Another thing,: how this should be expressed correctly:

class ProcessDefsSelect(allDefs: BindingSeq[ProcessDefinition], selected: Var[Option[ProcessDefinition]]) {

  @dom
  def render: Binding[html.Select] = {
    <select class="ui dropdown" onchange={e: Event => selected.value = allDefs.bind.find(_.id == e.target.asInstanceOf[html.Select].value)} >
      {for (pDef <- allDefs) yield {
      <option value={pDef.id} selected={selected.bind.exists(_.id == pDef.id)} >
        {pDef.name}
      </option>
    }}
    </select>
  }

}

simple select component. This impl doesnt work due to allDefs.bind invoked in callback function...

Wojtek Pituła
@Krever
assigning allDefs.bind to variable outside callback function works fine
Mustafa Kuscu
@mcku
I have a question https://stackoverflow.com/questions/53119126/binding-scala-component-to-string-conversion. In this Gitter channel, there was a discussion on how to convert a scalatags typed tag to string. I need a similar way to do that for a Binding[Element].
Mustafa Kuscu
@mcku
Would it be possible to use a third party library like that alongside with binding.scala? As an example, consider the example setting content of popup: https://github.com/fancellu/scalajs-leaflet/blob/master/example/src/main/scala/example/Leaflet2.scala#L25
How can i set dynamic content in the popup that depends on binding.scala content?
Maybe an idea could be to build a modified leaflet library that avoids the builders and promotes binding.scala concepts, which might be a novel approach to mapping.
Leonid Turnaev
@glmars
Why are you thinking it isn't possible? I suppose, you can try and if you will have a concrete problem, you can write stackoverflow question. As I know there is a link in Readme to an example project of the using Google maps with Binding.scala which can be helpful for you.
Mustafa Kuscu
@mcku
Well, i like using leaflet, my other project is using leaflet. The binding.scala + google maps tutorial has binding.scala components for the search box related data binding only. The map is bound to the dom by the leaflet.js itself. Therefore it is outside of the managed code, the leaflet code updates the dom directly. Therefore the problem becomes how to integrate these together. This is a similar problem in the react world, too. In the react world i was using react-leaflet for managing the lifecycle of the map's sub components (https://react-leaflet.js.org/docs/en/intro.html#lifecycle-process). But here i don't know if it is possible to extend or customize the life cycle of dom components, the map in particular, and relate them to those of the binding.scala components. It may be just easier to re-implement leaflet.js in binding.scala, because leaflet.js includes lots of custom event handling stuff which is simply redundant in the existing of binding.scala.
Mustafa Kuscu
@mcku

For instance, when a map is initialized by leaflet, the container that is associated with the map is 'marked', therefore after a re-rendering caused by .bind, the map may become unusable because it won't contain leaflet.js-originated stuff... This one can be avoided by careful coding.

But one other thing is to use a dom annotated component's value within the non-binding-aware, external library. This one i still don't know. extfunc(x.bind) would this be recalculated after x changes?

Mustafa Kuscu
@mcku

i realize that i might have been missing a basic feature until now. :/ i don't know how others use watch but watch does this. If i put the external func in Binding{} and add watch, it works. Binding{extfunc(x.bind)}.watch()

let me go and break my head.. (:|)

Mustafa Kuscu
@mcku
One more question. Let's say we have a single page app (SPA) and would like to use a legacy library that is jQuery based, such that some random elements need to be initialized by some jQuery plugin. The SPA renders totally different layouts depending on some conditions (like authentication), therefore it is not guaranteed after the first page load the elements are attached to the DOM. Is there a way to attach an initializer to a div just for this purpose, so that wherever the div is being used, it is going to get the initializer invoked? (If you know an answer and are willing to answer on SO, I can enter a question there, too.)
Mustafa Kuscu
@mcku
Just to make things clear, even workarounds like this after where dom.render() gets called did not help
def applyOnMount(selector: String, f: () => Unit):Unit = {
    val elemFound: Boolean = org.scalajs.dom.document.body.querySelectorAll(selector).length > 0
    if (!elemFound) {
      println(s"waiting for elem $selector")
      js.timers.setTimeout(Duration.seconds(1000).milliseconds) {
        println(s"recursing for $selector")
        applyOnMount(selector,f)
      }
    } else {
      println(s"applying on elem $selector")
      f
    }
  }
Kahli Burke
@kahliburke
I’d investigate
杨博 (Yang Bo)
@Atry
Have you search the answer of your question on StackOverflow?
Mustafa Kuscu
@mcku
Thanks for the recommendation, @kahliburke, although i was trying to stay within the binding.scala tooling like watch(),.. Would it be possible to implement it using watch()? I have not tested MutationObserver before, i will consider using it instead of re-implementing some existing components in binding.scala.
Mustafa Kuscu
@mcku
@Atry got your point. A similar example I was following was @sadhen's here: http://sadhen.com/blog/2017/01/02/binding-with-semantic.html
Mustafa Kuscu
@mcku
When things build up including routing, ui navigation, authentication, working with local and remote data and futurebindings, social media logins, google/leaflet maps, etc, some sort of best practices become necessary. It may be a good idea to keep a binding.scala starter project with up to date best practices for reference and building shared experience. I don't mind offering a starter skeleton for going through common scrutiny if it helps...
杨博 (Yang Bo)
@Atry
:+1: