A tiny eventbus library for vue 3
- It provides a plugin and composables for using event bus
- just simply plug it with your vue and it will take care of everything
- it's only 300 bytes (gzip)
npm i vue-signaler
In the main.js file, import the eventBus and use it as plugin
<script>
import { eventBus } from 'vue-signaler'
app.use(eventBus)
</script>
In the components, we can access the eventBus using the composable useEventBus
<script>
import { useEventBus } from 'vue-signaler'
const { eventBus } = useEventBus();
eventBus.on('eventName', (data)=>{
console.log(data)
})
eventBus.emit('eventName' , { name : 'rogue-striker' })
</script>