-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross-compile support for JVM #46
Comments
I like the idea of separating mount from HTML emission, as it seems simpler initially and would be more flexible. For instance, many MVC applications might make use of the same views that exist in monadic-html, but have no need to mount. Additionally, monadic-html is really "monadic-xml" at its heart, so this could be used in other XML-oriented projects (though less commonly so I'm sure). Other uses would undoubtedly need their own versions of mount. |
I'm not sure it's worth factoring out, the entire mount logic is a simple tree traversal of def mount0(parent: DomNode, child: XmlNode): Cancelable =
child match {
case e @ Elem(_, label, metadata, scope, child @ _*) =>
/* Create regular DOM node */
Cancelable { () => ... }
case e: EntityRef =>
/* Create text Node with the entity*/
Cancelable.empty
case Group(nodes) =>
val cancels = nodes.map(n => mountNode(parent, n))
Cancelable(() => cancels.foreach(_.cancel))
case a: Atom[_] => a.data match {
case n: XmlNode => mountNode(parent, n)
case rx: Rx[_] =>
var c1 = Cancelable.empty
val c2 = rx.impure.foreach { v =>
/* Remove previous node from the DOM */
c1.cancel
c1 = mountNode(parent, new Atom(v))
}
Cancelable { () => c1.cancel; c2.cancel }
case seq: Seq[_] => mountNode(parent, new Group(seq.map(new Atom(_))))
case primitive =>
val content = primitive.toString
if (!content.isEmpty)
parent.mountHere(/* Create text Node with primitive */)
Cancelable.empty
}
} |
As noted from @OlivierBlanvillain :
The text was updated successfully, but these errors were encountered: