Chatwoot/app/javascript/shared/helpers/CustomEventHelper.js

16 lines
411 B
JavaScript
Raw Normal View History

export const createEvent = eventName => {
let event;
if (typeof window.CustomEvent === 'function') {
event = new CustomEvent(eventName);
} else {
event = document.createEvent('CustomEvent');
event.initCustomEvent(eventName, false, false, null);
}
return event;
};
export const dispatchWindowEvent = eventName => {
const event = createEvent(eventName);
window.dispatchEvent(event);
};