12ee7e5d82
* feat: Add `chatwoot:ready` event listener on window * Add specs * Rename customEventHelper.js -> CustomEventHelper.js
15 lines
411 B
JavaScript
15 lines
411 B
JavaScript
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);
|
|
};
|