Last active
January 21, 2016 18:40
-
-
Save stanch/a80b60db1a1b871efe8b to your computer and use it in GitHub Desktop.
Demo fragments for my talk “What can we learn from composable DSLs?”
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Utils { | |
val disableCache = respondWithHeaders( | |
`Cache-Control`(`no-cache`, `max-age`(0), `must-revalidate`, `no-store`), | |
`Expires`(DateTime.MinValue) | |
) | |
} | |
object BooksRoutes { | |
val routes = path("books" / Segment) { id => | |
complete(id) | |
} | |
} | |
object AuthorRoutes { | |
val routes = path("authors" / "list") { | |
complete("Shakespear") | |
} | |
} | |
object Routes { | |
val routes = Utils.disableCache { | |
pathPrefix("v1" / "api") { | |
BookRoutes.routes ~ AuthorRoutes.routes | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val large = TextTweaks.large + TextTweaks.italic | |
val adaptive = hdpi ? large | Tweaks.blank | |
val hello = widget[TextView] <~ text("Hello World!") <~ adaptive | |
val button = widget[Button] <~ text("Click me!") | |
layout[LinearLayout]( | |
hello, | |
button | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nursery(teaser: String) = li( | |
em(teaser), " ", button("Show") | |
) | |
val lamb = nursery("Mary had a little lamb") | |
val star = nursery("Twinkle, twinkle, little star") | |
val rhymes = ul(lamb, star) | |
println(rhymes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment