Skip to content

Instantly share code, notes, and snippets.

@alextkachman
Created March 25, 2014 15:56
Show Gist options
  • Save alextkachman/9764892 to your computer and use it in GitHub Desktop.
Save alextkachman/9764892 to your computer and use it in GitHub Desktop.
Statically typed Angular with Kotlin
package angular.demo
import angular.*
object HelloWorldModule : Module("HelloWorld") {
val hello = constant("hello", "Hello")
val world: String by factory("world") {"World"}
}
object AppModule : Module("App",array(HelloWorldModule)) {
{
controller<AppScope>("AppController") {
phrase = HelloWorldModule.hello + ", " + HelloWorldModule.world
clickCount = 0
addClick = { clickCount++ }
watch("clickCount") { value ->
if (value == 5) {
clickCount = 0
}
}
}
controller<InnerScope>("InnerController") {
buttonText = "Click"
buttonClick = {
addClick()
}
}
}
}
native trait AppScope : Scope {
var phrase : String
var clickCount: Int
var addClick: ()->Unit
}
native trait InnerScope : AppScope {
var buttonText : String
var buttonClick : InnerScope.()->Unit
}
fun main(args: Array<String>) {
AppModule
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment