class MyButton : DefineSignals!(DeclareSignals!(HTMLElement, "onClick"), "onClick") { this(string id) { super(id, true); } string html() const { ... } } MyButton btn1 = new MyButton("btn1"); btn1.onClick.strongConnect(delegate(FiredContext ctx, WeakRef!(const(JSArrayCpp)) arr){ assert(ctx.sender == btn1); writeln("fired a signal by ", ctx); });