Skip to content

Instantly share code, notes, and snippets.

@HarryR
Created October 1, 2014 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarryR/41834169d05383fdaaeb to your computer and use it in GitHub Desktop.
Save HarryR/41834169d05383fdaaeb to your computer and use it in GitHub Desktop.
Callback type which allows either one Dynamic arg, or no args
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