UNPKG

mutants-appfx

Version:

appfx module

29 lines (26 loc) 791 B
const controllerEvents = new Map(); export const findActions = (target, eventName)=>{ if (!controllerEvents.has(target.__proto__.constructor) ){ return []; } const ctlpaths = controllerEvents.get(target.__proto__.constructor); return [...(ctlpaths[eventName] || [])]; } export default (eventName, mappings) => { return (target, name, descriptor) => { let ctlpaths; if (!controllerEvents.has(target.constructor)) { ctlpaths = {}; controllerEvents.set(target.constructor, ctlpaths); } else { ctlpaths = controllerEvents.get(target.constructor); } let eventPaths = ctlpaths[eventName]; if (!eventPaths) { eventPaths = new Set(); ctlpaths[eventName] = eventPaths; } eventPaths.add(name); return descriptor; } }