[dispatcher] add dispatcher macro
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package demo;
|
||||
|
||||
import demo.dispatch.DemoDispatcher;
|
||||
import haxework.net.JsonLoader;
|
||||
import demo.popup.ColorPopup;
|
||||
import haxework.App;
|
||||
@@ -30,16 +31,28 @@ import haxework.log.TraceLogger;
|
||||
}
|
||||
}
|
||||
|
||||
class Demo extends App {
|
||||
class Demo extends App implements DemoListener {
|
||||
|
||||
public static function main() {
|
||||
L.push(new TraceLogger());
|
||||
|
||||
var app = new App();
|
||||
var app = new Demo();
|
||||
app.resources.image.put("logo", HaxeLogo.resolve());
|
||||
Theme.setColor(0x33aa33);
|
||||
app.start(new DemoView());
|
||||
|
||||
var dispatcher = new DemoDispatcher();
|
||||
dispatcher.connect(app);
|
||||
dispatcher.test1Change.emit();
|
||||
dispatcher.test2Change.emit(1);
|
||||
dispatcher.test3Change.emit(1, "test");
|
||||
dispatcher.test4Change.emit(app);
|
||||
dispatcher.disconnect(app);
|
||||
dispatcher.test1Change.emit();
|
||||
dispatcher.test2Change.emit(1);
|
||||
dispatcher.test3Change.emit(1, "test");
|
||||
dispatcher.test4Change.emit(app);
|
||||
|
||||
new JsonLoader().GET("http://umix.tv/channel/data2/renova.json")
|
||||
.then(function(data:Array<Model>) {
|
||||
app.resources.any.put("data", data);
|
||||
@@ -47,4 +60,21 @@ class Demo extends App {
|
||||
})
|
||||
.catchError(function(error) trace(error));
|
||||
}
|
||||
|
||||
public function test1():Void {
|
||||
trace('test1');
|
||||
}
|
||||
|
||||
public function test2(a:Int):Void {
|
||||
trace('test2', a);
|
||||
}
|
||||
|
||||
public function test3(a:Int, b:String):Void {
|
||||
trace('test3', a, b);
|
||||
}
|
||||
|
||||
public function test4(app: App):Void {
|
||||
trace('test4', app);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
14
demo/src/demo/dispatch/DemoDispatcher.hx
Normal file
14
demo/src/demo/dispatch/DemoDispatcher.hx
Normal file
@@ -0,0 +1,14 @@
|
||||
package demo.dispatch;
|
||||
|
||||
import haxework.App;
|
||||
|
||||
interface DemoListener {
|
||||
public function test1():Void;
|
||||
public function test2(a:Int):Void;
|
||||
public function test3(a:Int, b:String):Void;
|
||||
public function test4(app:App):Void;
|
||||
}
|
||||
|
||||
@:dispatcher(DemoListener) class DemoDispatcher {
|
||||
public function new() {}
|
||||
}
|
||||
Reference in New Issue
Block a user