Haxe: how to declare "static" methods in an Interface? -
this question has been asked (and answered) in old haxe forums on babble ... appears that entire forum system no longer functions. therefore, i'm asking here:
in haxe, need declare "interface" class includes static function, "instance()." when so:
you can't declare static fields in interfaces
so remove word "static" public function instance() [...]
, , this:
field instance needed [...] missing.
apparently "catch-22." there must easy solution. it?
as stated language doesn't allow static fields on interfaces. choice intentional. thing doesn't exist inheriting static fields.
there several ways structure code avoid such usage in point of view doesn't give many advantages. factory pattern or di approach (i suggest minject library) seems obvious.
given comment below go typedef
instead of interface:
typedef getinstance = void -> void;
you can pass typedef around same interface advantage can use both static , instance methods satisfy signature.
Comments
Post a Comment