Commit 1b2eda53 authored by Mathieu leclaire's avatar Mathieu leclaire

autowire 0.1.4

parent a7af82c1
......@@ -29,7 +29,7 @@ object Client {
val submitButton1 = button("Click me")(
cursor := "pointer",
onclick := { () =>
Post[Api](_.hello(5)).foreach { i =>
Post(_.hello(5)).foreach { i =>
helloValue() = helloValue() + i
}
}
......@@ -38,7 +38,7 @@ object Client {
val submitButton2 = button("Click me")(
cursor := "pointer",
onclick := { () =>
Post[Api](_.caseClass).foreach { s =>
Post(_.caseClass).foreach { s =>
caseClassValue() = s.hello
}
false
......@@ -56,7 +56,7 @@ object Client {
}
object Post extends autowire.Client[Web] {
object Post extends autowire.Client[Api] {
override def callRequest(req: Request): Future[String] = {
val url = req.path.mkString("/")
......
......@@ -28,7 +28,7 @@ object ScalaTraJSTagsWireRxBuild extends Build {
scalaVersion := ScalaVersion,
resolvers ++= Resolvers,
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "autowire" % "0.1.2",
"com.lihaoyi" %%% "autowire" % "0.1.4",
"com.lihaoyi" %%% "upickle" % "0.2.1",
"com.scalatags" %%% "scalatags" % "0.4.0",
"com.scalarx" %%% "scalarx" % "0.2.6",
......@@ -50,7 +50,7 @@ object ScalaTraJSTagsWireRxBuild extends Build {
scalaVersion := ScalaVersion,
resolvers ++= Resolvers,
libraryDependencies ++= Seq(
"com.lihaoyi" %% "autowire" % "0.1.2",
"com.lihaoyi" %% "autowire" % "0.1.4",
"com.lihaoyi" %%% "upickle" % "0.2.1",
"com.scalatags" %%% "scalatags" % "0.4.0",
"org.scala-lang.modules.scalajs" %%% "scalajs-dom" % "0.6",
......
......@@ -37,7 +37,7 @@ class MyScalatraServlet extends ScalatraServlet {
}
post(s"/$basePath/*") {
Await.result(autowire.Macros.route[Web](Server)(
Await.result(autowire.Macros.route[Api](Server)(
autowire.Request(Seq(basePath) ++ multiParams("splat").head.split("/"),
upickle.read[Map[String, String]](request.body))
), Duration.Inf)
......
package shared
import scala.annotation.ClassfileAnnotation
import scala.scalajs.js.annotation.JSExport
class Web extends ClassfileAnnotation
@Web
@JSExport
case class MyCaseClass(hello: String)
@Web
trait Api {
def hello(a: Int): Int
def caseClass(): MyCaseClass
......
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