@awesome-dev/server-event-emitter
Advanced tools
Comparing version
export declare abstract class BaseEvent<Payload = unknown> { | ||
readonly payload: Payload; | ||
constructor(payload: Payload); | ||
static getEventName(event: BaseEvent): string; | ||
} | ||
export declare function parseEventName(name: string): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BaseEvent = void 0; | ||
exports.parseEventName = exports.BaseEvent = void 0; | ||
const utils_1 = require("@awesome-dev/utils"); | ||
@@ -9,7 +9,8 @@ class BaseEvent { | ||
} | ||
static getEventName(event) { | ||
return (0, utils_1.toKebabCase)(event.constructor.name.replace('Event', '')); | ||
} | ||
} | ||
exports.BaseEvent = BaseEvent; | ||
function parseEventName(name) { | ||
return (0, utils_1.toKebabCase)(name.replace('Event', '')); | ||
} | ||
exports.parseEventName = parseEventName; | ||
//# sourceMappingURL=base-event.js.map |
import { BaseEvent } from '../base-event'; | ||
export declare function Handler(event: BaseEvent): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void; | ||
type TargetEvent = { | ||
new (): BaseEvent; | ||
}; | ||
export declare function Handler(targetEvent: TargetEvent): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void; | ||
export {}; |
@@ -7,6 +7,6 @@ "use strict"; | ||
const base_event_1 = require("../base-event"); | ||
function Handler(event) { | ||
return (0, common_1.applyDecorators)((0, event_emitter_1.OnEvent)(base_event_1.BaseEvent.getEventName(event))); | ||
function Handler(targetEvent) { | ||
return (0, common_1.applyDecorators)((0, event_emitter_1.OnEvent)((0, base_event_1.parseEventName)(targetEvent.name))); | ||
} | ||
exports.Handler = Handler; | ||
//# sourceMappingURL=handler.js.map |
@@ -21,3 +21,3 @@ "use strict"; | ||
emit(event) { | ||
return this.eventEmitter.emit(base_event_1.BaseEvent.getEventName(event), event); | ||
return this.eventEmitter.emit((0, base_event_1.parseEventName)(event.constructor.name), event); | ||
} | ||
@@ -24,0 +24,0 @@ }; |
export * from './decorators'; | ||
export * from './base-event'; | ||
export * from './event-emitter'; | ||
export * from './module'; |
@@ -18,4 +18,5 @@ "use strict"; | ||
__exportStar(require("./decorators"), exports); | ||
__exportStar(require("./base-event"), exports); | ||
__exportStar(require("./event-emitter"), exports); | ||
__exportStar(require("./module"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@awesome-dev/server-event-emitter", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
12401
2.96%153
4.79%