Last active
December 18, 2015 12:19
-
-
Save cambiata/5781850 to your computer and use it in GitHub Desktop.
HaxeDCI Greeting example - https://github.com/ciscoheat/haxedci
This file contains 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 ; | |
import neko.Lib; | |
import dci.Context; | |
/** | |
* ... | |
* @author | |
*/ | |
class Main | |
{ | |
static function main() | |
{ | |
new Greeting({name:"Anna"}, "Hello", {name:"World"}).greet(); | |
} | |
} | |
typedef ISomeone = { | |
name: String, | |
}; | |
typedef IMessage = String; | |
@:build(Dci.role(Greeting)) | |
private abstract Someone(ISomeone) | |
{ | |
public function name() | |
{ | |
return this.name; | |
} | |
} | |
@:build(Dci.role(Greeting)) | |
private abstract Message(IMessage) | |
{} | |
class Greeting implements Context | |
{ | |
@role var sender: Someone; | |
@role var message: Message; | |
@role var recipient: Someone; | |
public function new (sender:ISomeone, message:IMessage, recipient:ISomeone) | |
{ | |
this.sender = new Someone(sender); | |
this.message = new Message(message); | |
this.recipient = new Someone(recipient); | |
} | |
public function greet() | |
{ | |
trace('${sender.name()} says: "$message, ${recipient.name()}!".'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment