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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');

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

exports.useListener = useListener;
exports.useResize = useResize;
//# sourceMappingURL=useListener.js.map
