jokade / angulate2

Scala.js bindings for Angular
MIT License
87 stars 15 forks source link

Generalize Data annotation #58

Open jokade opened 7 years ago

jokade commented 7 years ago

Case classes annotated with @Data should be translated into plain JS objects when compiled with Scala.js (and be ignored with Scala/JVM).

Example: when Node is defined as

@Data
case class Node(id: Int, label: Option[String] = None, children: Seq[Node] = Nil)

then

Node(1, label = Some("root"), children = Seq(
  Node(2, label = Some("child1")),
  Node(3)
))

should translate to

{id: 1, label: "root", children: [{id: 2, label: "child1", children: []}, {id: 3, label: undefined, children: []}]}