UNPKG

@empathyco/x-components

Version:
35 lines (32 loc) 955 B
import { defineComponent } from 'vue'; import { useXBus } from '../composables/use-x-bus.js'; /** * This component helps to subscribe to any {@link XEvent} with custom callbacks using Vue * listeners API. * * @public */ var _sfc_main = defineComponent({ name: 'GlobalXBus', props: { listeners: { type: Object, required: true, }, }, setup(props) { const xBus = useXBus(); /** * Handles a subscription to all the events provided in the listeners with the function that * will execute the callback. */ Object.entries(props.listeners).forEach(([eventName, callback]) => { xBus.on(eventName, true).subscribe(({ eventPayload, metadata }) => { callback(eventPayload, metadata); }); }); return () => ''; }, }); export { _sfc_main as default }; //# sourceMappingURL=global-x-bus.vue.js.map