I have forked your example and have made it work with a Global EventBus using EventBus.$emit and EventBus.$on. This way any Component can choose to listen to this event which makes for a cleaner solution I think.
Alex is an award-winning designer, Senior Front-End Dev @Healthx, and an avid sticker maker. He has worked for over 10 years as a web developer and designer.
Hey George! Your fork looks great, thanks for providing this.
I did look into using EventBus.$emit for the example, but I was trying to keep the components as modular as possible. While creating the file event-bus.js is not a huge lift, it is an additional item the component is dependent on.
I think your solution is 100% acceptable.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice writeup Alex, thanks for sharing.
I have forked your example and have made it work with a Global EventBus using EventBus.$emit and EventBus.$on. This way any Component can choose to listen to this event which makes for a cleaner solution I think.
You can see my changes here codesandbox.io/s/mq2yl9lw8p
Do you know why would someone choose one over the other method ?
This was really helpful for a beginner like me, thanks!
Hey George! Your fork looks great, thanks for providing this.
I did look into using
EventBus.$emit
for the example, but I was trying to keep the components as modular as possible. While creating the fileevent-bus.js
is not a huge lift, it is an additional item the component is dependent on.I think your solution is 100% acceptable.