I’m working on a toolset/haxelib and I want to provide easy ways for my users to override existing behaviors, and while I understand that inheritance offers the override keyword, I don’t want to make my users override my whole library just to change one class type and it’s behavior. As a loose example:
public static var MY_CLASS:Class<MyParentClass>;
function makeNewClass() {
return Type.createInstance(MY_CLASS, []);
}
function replaceClass() {
MY_CLASS = Class<MyChildClass>;
}
I want to be able to set MY_CLASS
to the child/custom class the users would want to use. I understand that this is very likely not the correct way to use this, and whenever I have tried to use this Type.createInstance()
has returned null
every time and I’m not sure what I’m doing wrong. Any help for this would be appreciated, thank you for your time!