@empathyco/x-components
Version:
Empathy X Components
40 lines (27 loc) • 1.02 kB
Markdown
title: GlobalXBus
# GlobalXBus
This component helps to subscribe to any XEvent with custom callbacks using Vue
listeners API.
## Props
| Name | Description | Type | Default |
| ---------------------- | ----------- | ---------------------------- | ------------- |
| <code>listeners</code> | | <code>XEventListeners</code> | <code></code> |
## Events
This component emits no own events, but you can subscribe to any X Event using Vue listeners
## See it in action
This component does not render anything. Its only responsibility is to facilitate listening to any X
Event by using the prop `listeners`
```vue
<template>
<GlobalXBus :listeners="{ UserAcceptedAQuery: printQuery }" />
</template>
<script setup>
import { GlobalXBus } from "@empathyco/x-components";
function printQuery(query, metadata) {
console.log("My new query is:", query);
console.log("And has been triggered by this DOM element:", metadata.target);
}
</script>
```