Comments (13)
@vodkaka Could you provide an example of this? I attempted defining it, but I am not familiar enough with Scala and Binding.scala to get it working.
EDIT: After some googling I came across this solution from reddit:
https://www.reddit.com/r/scala/comments/5se6hj/scalajs_reactive_frontend_framework/ddfhzqu/?st=iyxrpkul&sh=dc3d099d
implicit def makeIntellijHappy(x: scala.xml.Node): Binding[org.scalajs.dom.raw.Node] = ???
from binding.scala.
This issue should be reported at https://youtrack.jetbrains.com
from binding.scala.
Or you could try Scala IDE for Eclipse, which handles macros.
from binding.scala.
I ran into the same issue. I investigated writing a plugin to support macro highlighting, but I'm unsure of how to change the return type of annotated vals and defs.
I submitted a question to the IDEA Scala forum here with more details.
from binding.scala.
I am aware that the problem with highlighting is IntelliJ's but my question was about the possibility of using the library without the macro. Anyway, thank you very much for answering.
from binding.scala.
Scala's xml library is pretty weird. I doubt it would be possible to replace the macro by defining an implicit conversion from xml.Element to Binding[ ], but perhaps @Atry has some insight on the matter.
from binding.scala.
Binding.scala changes types of XML literals via macros. IntelliJ IDEA seems using its own typer, which does not fully understand macros and other complex Scala syntax, even for those code that does not involve macros.
I have many Scala files that do not use macros. They are still red marked by IntelliJ IDEA.
from binding.scala.
@joseraya Thought a bit more about it, and you can avoid having to use the @dom
annotation.
Replace xml literals with scalatags's JSDom.
For example:
import scalatags.JsDom.all._
def clicker(i: Var[Int]) = Binding[Node](
div(
button(onclick := {() => i := i.get + 1})("click me"),
p("num times clicked: " + {i.bind.toString}),
tag("test-tag")("this is a test")
).render
)
def app = Binding[Node]{
val i = Var(0)
div({clicker(i).bind}).render
}
def main(): Unit = {
scalajs.dom.render(document.body, app)
}
The only downside (upside? ;) ) is that you lose xml literals
from binding.scala.
The entire app
is recreated whenever i
changes if you don't use XML literals.
from binding.scala.
Yeah, just realized this :(
from binding.scala.
XHTML literals in @dom
methods create very sophisticated ScalaTags code able to partially data-bind on each element and element.
I bet you never want to hard-code the code.
from binding.scala.
@deontologic @joseraya
there is a trick for you, define an implicit conversion (Node -> Binding[Node])
the complier won't do the implicit conversion, it knows what happen
but intellij will be tricked, so all type is right
from binding.scala.
@vodkaka lol, nice
from binding.scala.
Related Issues (20)
- FXML: Enable opening pop-up window at a specified location
- Null cache exception in FlatMap HOT 8
- Entity references in attribute values do not compile
- Referring to non-existent method com.thoughtworks.binding.FutureBinding$.apply(scala.concurrent.Future,scala.concurrent.ExecutionContext) HOT 1
- Event handlers in custom tags HOT 1
- data prefix does not (it should) set the attribute to null if the initial value is null HOT 1
- FutureBinding compare with React hooks HOT 1
- Make Binding.value be public HOT 16
- Vars.all is not triggerred HOT 2
- := deprecated, how to use value_= ? HOT 3
- dom module is missing for version `12.0.0-M0` HOT 1
- V12 eta HOT 2
- Vars size binding HOT 3
- Conversion from Binding[Iterable[A]] to BindingSeq[A] HOT 4
- Using BindingSeq in an implicit value class HOT 1
- Use @html to create a table, what is returned is scala.xml.NodeBuffer, and what is needed is BindableSeq[org.scalajs.dom.Node], how to convert? HOT 4
- Dependency `scalajs-dom` is out dated HOT 1
- The last element in HTML interpolation are inserted twice (Binding.scala 13.x)
- Code in `ReadMe.md` failed for unkonow reason. HOT 8
- Support for `Scala.js1.x` & `Scala2.12`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binding.scala.