[Vuejs]-Nuxt EventBus โ€“ usage for many events

0๐Ÿ‘

Itโ€™s okay if you need to add certain event listeners here and there. Just make sure you remove them when to component is destroyed, e.g.

mounted() {
  window.addEventListener('eventName', yourMethod);
},

beforeDestroy() {
  window.removeEventListener('eventName', yourMethod);
}

0๐Ÿ‘

How about using debouncer for a short time limit.

Iโ€™m guessing that your DOM is not updating on every event and it takes some to self update. So slow down the event bus emit like in every 50/100 ms there will be an event fire. You can emit to event bus on every 50 MiliSecond or as per as your need. That would be helpful even if you solve the problem in other way.

Leave a comment