@toast-ui/chart
Version:
TOAST UI Application: Chart
17 lines (16 loc) • 398 B
JavaScript
export default class EventEmitter {
constructor() {
this.handlers = [];
}
on(type, handler) {
if (!this.handlers[type]) {
this.handlers[type] = [];
}
this.handlers[type].push(handler);
}
emit(type, ...args) {
if (this.handlers[type]) {
this.handlers[type].forEach((handler) => handler(...args));
}
}
}