Gleb Kanterov
gleb@kanterov.ru
> ["10", "10", "10", "10"]
> .map(parseInt)
[10, NaN, 2, 3]
> List("10", "10", "10", "10")
> .map(parseInt)
List(10, 10, 10, 10)
def main(div: html.Div) = {
val child = dom.document
.createElement("div")
child.textContent =
"Hi from Scala-js-dom"
div.appendChild(child)
}
val myStyle = style(
margin(12 px, auto),
&.hover(
cursor.zoomIn
),
&(media.not.handheld.landscape.maxWidth(640 px))(
width(400 px)
)
)
val button = style(
addClassNames("btn", "btn-default"),
textAlign.center
)
trait Api {
def order(itemIds: List[Int]): Order
def submit(order: Order): Unit
}
val client = Ajax[Api]
val z: Future[Unit] = for {
order <- client.order(itemIds).call()
result <- client.submit(order).call()
} yield result
val z: Future[Unit] = async {
val order = await(client.order(itemIds).call())
val result = await(client.submit(order).call())
result
}
@scalax
def render(self: This) = {
val todo = self.state.todos.count(!_.completed)
<section id="todoapp">
<header id="header">
<h1>todos</h1>
<input id="new-todo"
onChange={self.onChange}
onKeyUp={self.onKeyPress}
value={self.state.text}
placeholder="What needs to be done?"
autofocus={true}></input>
</header>
</section>
}
case class Person(name: String, title: String)
object Person {
implicit val codec = Codec[Person]
}
sealed trait Tree
case class Node(l: Tree, r: Tree) extends Tree
case class Leaf(n: Int) extends Tree
object Tree {
implicit lazy val codec: Codec[Tree] = {
discriminated[Tree]
.by(uint8)
.typecase2(0, int32.as[Leaf])
.typecase2(1, lazily { (codec :: codec).as[Node] })
}
}
property("reverse") = Prop.forAll { l: List[String] =>
l.reverse.reverse == l
}
property("fib") = Prop.forAll { i suchThat (_ > 2) =>
fib(i) ?= fib(i - 1) + fib(i - 2)
}