/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import { onMounted, onBeforeUnmount } from 'vue';

function useListener(type, listener) {
  onMounted(function () {
    window.addEventListener(type, listener);
  });
  onBeforeUnmount(function () {
    window.removeEventListener(type, listener);
  });
}
function useResize(listener, observer) {
  useListener("resize", listener);
  var resizeObserver = null;
  onMounted(function () {
    if (!window.ResizeObserver || !observer) return;
    resizeObserver = new window.ResizeObserver(listener);
    resizeObserver.observe(observer);
  });
  onBeforeUnmount(function () {
    var _resizeObserver;
    (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.disconnect();
  });
}

export { useListener, useResize };
//# sourceMappingURL=useListener.mjs.map
