function EventHandler(type: string, selector: (self: U) => Function) { let memberDecorator = ecs.createMemberDecorator((entity, component) => { let listener = selector(entity); return new EventHandlerComponent(component, type, listener, entity) }); return memberDecorator; } class EventHandlerComponent implements ecs.Component { constructor(public component: eui.Component, public type: string, public listener: Function, public thisObject: any) { } activate() { this.component.addEventListener(this.type, this.listener, this.thisObject); // ui.addEventListener(this.type,) } }