Hello, I am currently doing something like this:
myFunc(tracer);
function tracer(message:String):void{
trace(message);
}
function myFunc(callback:Function):void{
callback("Hello");
}
Now, this works fine. But how can the function myFunc know, if the given callback function accepts the correct number and type of arguments in its signature?
I want to avoid that I call something like this somewhere in my code:
myFunc(tracer2);
function tracer2():void{
trace("done");
}
function myFunc(callback:Function):void{
// Argument mismatch!
callback("Hello");
}
Is there a way to do something like this, in order to use compiler warnings/error messages and thus avoid exceptions at runtime?
// Won't work :-(
function myFunc(callback(message:String):Function):{
callback("Hello");
}