@zhsz/cool-design-crud
Version:
35 lines (34 loc) • 797 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index = require("./utils/index.js");
const crudList = [];
const emitter = {
list: [],
init(events) {
if (events && index.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 });
}
};
exports.crudList = crudList;
exports.emitter = emitter;