Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/robotlegs/bender/framework/impl/MessageDispatcher.hx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,26 @@ class Callback {
public var length:Int = 0;

public function new(value:Dynamic) {
#if flash
length = Reflect.field(value, "length");
call = (v1:Dynamic, v2:Dynamic) -> {
if (length == 0) {
var func0:Void->Void = value;
func0();
}
else if (length == 1) {
var func1:Dynamic->Void = value;
func1(v1);
}
else if (length == 2) {
var func2:Dynamic->Dynamic->Void = value;
func2(v1, v2);
}
else {
throw "Bad handler signature";
}
}
#else
var func0:Void->Void = null;
try {
func0 = value;
Expand Down Expand Up @@ -207,5 +227,6 @@ class Callback {
}
}
}
#end
}
}