mirror of https://github.com/mue/mue.git
20 lines
373 B
JavaScript
20 lines
373 B
JavaScript
export default class EventBus {
|
|
static on(event, callback) {
|
|
document.addEventListener(event, (e) => {
|
|
callback(e.detail);
|
|
});
|
|
}
|
|
|
|
static dispatch(event, data) {
|
|
document.dispatchEvent(
|
|
new CustomEvent(event, {
|
|
detail: data,
|
|
}),
|
|
);
|
|
}
|
|
|
|
static off(event, callback) {
|
|
document.removeEventListener(event, callback);
|
|
}
|
|
}
|