Skip to content

Instantly share code, notes, and snippets.

@bithavoc
Created December 25, 2013 16:09
Show Gist options
  • Select an option

  • Save bithavoc/8124548 to your computer and use it in GitHub Desktop.

Select an option

Save bithavoc/8124548 to your computer and use it in GitHub Desktop.
Example of Events.d, the first Event Model for D programming language
//
// http://blog.heapsource.com/post/71111508527/events-d
//
import std.stdio;
import std.string;
import events;
void main() {
auto event = new EventList!(string, int);
auto trigger = event.own;
event ^ (age) {
return "first age is %d".format(age);
};
event ^ (age) {
return "second age is %d".format(age);
};
event.add((age) {
return "third age is %d".format(age);
});
auto text = trigger(30);
text.writeln;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment