I want to create a global event bus with Nuxt, (see here). My first instinct was to create a middleware like this:
export default function () {
let eventBus = new Vue();
return eventBus;
}
But I don't have access to the Vue instance in the middleware, I'm not sure where I can put the following code so I can emit and receive events across all pages/components.
I don't really want to import a file into every single component/page that uses the event bus, as it defeats the object of it being globally accessible. Anyone know a way I can achieve this?
Thanks!
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1000">#c1000</a>)</em></sub></div>