import { useEffect } from "react";
import { publish } from "pubsub-js";
import { HOST_WINDOW_RESIZED } from "../utils/constants.js";
const useWindowSizeChange = () => {
  useEffect(() => {
    if (window.ResizeObserver) {
      const observer = new ResizeObserver((entries) => {
        publish(HOST_WINDOW_RESIZED, entries && entries[0]);
      });
      observer.observe(window.document.documentElement);
      return () => {
        observer.unobserve(window.document.documentElement);
      };
    }
    return () => {
    };
  }, []);
};
export {
  useWindowSizeChange
};
