I assume that T is a generic type, and in that case it cannot be used in a function (Std.isOfType()) where an actual value (eg. an instance of T) is required.
It’s difficult to understand what you’re trying to achieve with this code, maybe try this instead of T in the aforementioned code
package;
import haxe.Exception;
import haxe.Constraints.Function;
/**
* @author Sirox228
* @see https://github.com/Sirox228/CustomEvents/
*/
class Event<T>
{
public function new() {
if (!Std.isOfType(T, Function))
throw new Exception("type of Event must be function");
trace("new Event successful!");
}
public function createEvent(event:String) {
if (!Reflect.hasField(this, event))
Reflect.setProperty(this, event, event);
}
public function addEventCallback(callback:T, event:String) {
if (!Reflect.hasField(this, event))
throw new Exception("no such Event, use createEvent to add one.");
else
Reflect.setProperty(this, event + "callback", callback);
}
public function trigger(event:String, args:Array<Dynamic>):Dynamic {
if (Reflect.hasField(this, event) && Reflect.hasField(this, event + "callback"))
return Reflect.callMethod(this, Reflect.getProperty(this, event + "callback"), args);
else {
if (!Reflect.hasField(this, event) && Reflect.hasField(this, event + "callback"))
throw new Exception("no such Event, use createEvent to add one.");
else if (!Reflect.hasField(this, event + "callback") && Reflect.hasField(this, event))
throw new Exception("no such Event, use addEventCallback to add one.");
else
throw new Exception("no such event or callback, use createEvent, then addEventCallback to add them.");
}
return "haxe won't compile without this return so idk";
}
}