UNPKG

vue-hooks-plus

Version:
19 lines (18 loc) 630 B
"use strict"; const vue = require("vue"); const event = require("./event"); function useEventEmitter(options) { const eventRef = vue.ref(); const eventEmitterOptions = vue.computed(() => options != null ? options : { global: false }); if (!eventRef.value) { eventRef.value = eventEmitterOptions.value.global ? eventRef.value = event.eventEmitterOverall : eventRef.value = new event.EventEmitter(); } vue.watchEffect((onInvalidate) => { onInvalidate(() => { var _a; return (_a = eventRef.value) == null ? void 0 : _a.clear(); }); }); return eventRef.value; } module.exports = useEventEmitter;