Commit 69475dc0 authored by Mathieu leclaire's avatar Mathieu leclaire

Get case class from the server

parent 1f3c1a88
...@@ -37,16 +37,17 @@ object Client { ...@@ -37,16 +37,17 @@ object Client {
val submitButton2 = button("Click me")( val submitButton2 = button("Click me")(
cursor := "pointer", cursor := "pointer",
onclick := { () => onclick := { () =>
Post[Api](_.caseClass(MyCaseClass("Hello !"))).foreach { s => Post[Api](_.caseClass).foreach { s =>
caseClassValue() = s caseClassValue() = s.hello
} }
false false
} }
).render ).render
Rx {
dom.document.body.appendChild(submitButton1) dom.document.body.appendChild(submitButton1)
dom.document.body.appendChild(submitButton2) dom.document.body.appendChild(submitButton2)
Rx {
dom.document.body.appendChild(h1(helloValue).render) dom.document.body.appendChild(h1(helloValue).render)
dom.document.body.appendChild(h1(caseClassValue).render) dom.document.body.appendChild(h1(caseClassValue).render)
} }
......
...@@ -11,7 +11,7 @@ import scala.concurrent.Await ...@@ -11,7 +11,7 @@ import scala.concurrent.Await
object Server extends Api { object Server extends Api {
def hello(a: Int) = a * 3 def hello(a: Int) = a * 3
def caseClass(c: MyCaseClass) = c.oo def caseClass = MyCaseClass("Hello !")
} }
class MyScalatraServlet extends ServertestStack { class MyScalatraServlet extends ServertestStack {
......
...@@ -5,12 +5,13 @@ import scala.scalajs.js.annotation.JSExport ...@@ -5,12 +5,13 @@ import scala.scalajs.js.annotation.JSExport
class Web extends ClassfileAnnotation class Web extends ClassfileAnnotation
@Web
@JSExport @JSExport
case class MyCaseClass(oo: String) case class MyCaseClass(hello: String)
@Web @Web
trait Api { trait Api {
def hello(a: Int): Int def hello(a: Int): Int
def caseClass(cc: MyCaseClass): String def caseClass(): MyCaseClass
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment