UNPKG

vue-hooks-plus

Version:
20 lines (19 loc) 541 B
import { onScopeDispose } from "vue"; import { eventEmitterOverall, EventEmitter } from "./event"; import { useEventEmitterSubscription } from "./event"; function useEventEmitter(options) { var _a; const isGlobal = (_a = options == null ? void 0 : options.global) != null ? _a : false; if (isGlobal) { return eventEmitterOverall; } const localEmitter = new EventEmitter(); onScopeDispose(() => { localEmitter.clear(); }); return localEmitter; } export { useEventEmitter as default, useEventEmitterSubscription };