Created
March 25, 2014 15:56
-
-
Save alextkachman/9764892 to your computer and use it in GitHub Desktop.
Statically typed Angular with Kotlin
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
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