UNPKG

@zhsz/cool-design-crud

Version:

35 lines (34 loc) 685 B
import { isObject } from "./utils/index.mjs"; const crudList = []; const emitter = { list: [], init(events) { if (events && isObject(events)) { for (const i in events) { this.on(i, events[i]); } } else { console.error("Events error"); } }, emit(name, data) { this.list.forEach((e) => { const [_name] = e.name.split("-"); if (name === _name) { e.callback(data, { crudList, refresh(params) { crudList.forEach((c) => c.refresh(params)); } }); } }); }, on(name, callback) { this.list.push({ name, callback }); } }; export { crudList, emitter };