Local event bus in router component/mixin context only

Hello, I wanted to check if this is the correct way to do this. I am trying to create a local event bus for router component/mixins that only broadcast event on that component instead of on global app.

This code is working, but it feels incorrect to include Framework7 twice in the project, but maybe its OK?

import Framework7 from 'framework7';

export default {
    data() {
        return {
            localEventBus: new Framework7.Events(),
        }
    },
    mounted() {
        let self = this

        self.localEventBus.on('do-the-thing', () => {
            // take some action...
        })
    },
    methods: {
        doTheThing() {
            let self = this

            self.localEventBus.emit('do-the-thing')
        }
    }
}

Maybe there is a better way to do this? I have a mixin that will have almost 20 events, so I would prefer to just have those event handlers on router component/mixin scope only.

Your code is correct…

Thanks for checking!

To avoid it from double including make sure you are always use same imports for Framework7 across all files.