/**
 * resizeObserverService.ts
 */
const subscribers = new Map();
const observer = new ResizeObserver(entries => {
    requestAnimationFrame(() => {
        for (const entry of entries) {
            const callback = subscribers.get(entry.target);
            if (callback)
                callback();
        }
    });
});
/**
 * Register an element to the SINGLE global observer.
 */
export const subscribe = (el, callback) => {
    subscribers.set(el, callback);
    observer.observe(el);
    return () => {
        observer.unobserve(el);
        subscribers.delete(el);
    };
};
//# sourceMappingURL=resizeObserverService.js.map