I'm newcomer to programming world and I'm confused with some terms when it comes to talk about events
so I want an explanation about what is meant with
and what is the order of their use
Moreover I came across this code
code in js file
document.addEventListener('event-test', (event) => {
const eventTest = event;
if (eventTest) {
const test1 = eventTest.id;
if (eventTest.type === 'name') {
document.dispatchEvent(new CustomEvent('name-set', {detail: {
id: eventTest.id,
}}));
}
}
});
code in vue file
created() {
this.$root.$on('name-set', this.obj);
this.init();
},
could you explain how does it work and what should it do ?