Created
October 1, 2014 14:02
-
-
Save HarryR/41834169d05383fdaaeb to your computer and use it in GitHub Desktop.
Callback type which allows either one Dynamic arg, or no args
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
abstract Callback(Dynamic->Void) from Dynamic->Void { | |
inline function new(f) | |
this = f; | |
public inline function invoke(data:Dynamic):Void | |
(this)(data); | |
@:from static function fromNiladic(f:Void->Void):Callback | |
return new Callback(function (x) f()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment