General questions should be asked on StackOverflow, not here. This room focuses on development of Binding.scala.
Atry on master
Update scalatest to 3.2.3 Merge pull request #309 from sc… (compare)
Atry on master
Update sbt-pgp to 2.1.1 Merge pull request #306 from sc… (compare)
Atry on master
Update sbt-scalajs, scalajs-com… Merge pull request #307 from sc… (compare)
Atry on master
Update sbt to 1.4.6 Merge pull request #308 from sc… (compare)
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...
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?
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.)
dom.render()
gets called did not helpdef 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
}
}
subview1
and subview2
accept Binding
as parameters instead of raw values, in order to partially rendering subviews that when only parts of store
are changed.
Var
used in the entire application.
copy
(which @atry mentioned the demo) is the killer feature (would it be a bold statement to claim that it is something JS/TS world never had?) and can implement redux very easily. and you don't code on the overly-async javascript, instead scala and execution order is not an issue afaik (once upon a time I was banging my head with promise chains). Then the redux is not necessary because the state is already there in a stable manner. In JS world keeping a global state would be very unstable and would be hard to detect and reason on who modifies what. But simply you don't have such language-originated deficiencies in ScalaJs. That's a summary of my overall impression so far.
@mcku
Using MutationObserver, I am able to use jQuery based semantic-ui components without rewriting them in binding.scala from scratch
Could you check something like this: https://gist.github.com/glmars/a597f7c28931a38e2e9b3262279889a9 ?
The main ideas are using Element
based selector in jQuery instead of string
based and initializing of control right after creation.
{t("hello").bind}
gives the correct translation. The idea came from here: https://lingui.js.org/tutorials/react-patterns.html#id1 and i think it is good, and that idea can be ported to scalajs
watch
/render
/bind
or something like this? In our case initialization after creation works well with https://getmdl.io/ and https://materializecss.com