Próbuje tworzyć własne eventy w JS.
const cookiesAccepted = createEvent('cookies.accepted')
W jaki sposób je wykorzystywać?
if (getCookie('isVisited') !== 'true') {
console.log('first visit')
setCookie('isVisited', 'true', 365)
components[i].dispatchEvent(firstVisit)
} else {
console.log('another visit')
components[i].dispatchEvent(anotherVisit)
}
components[i].addEventListener('cookies.firstVisit', () => {
console.log('qwe')
})
components[i].addEventListener('cookies.anotherVisit', (event) => {
console.log('qwe')
}, false)
W miejscu, gdzie jest addEventListener nie nastepuje żadna akcja.