import { useLayoutEffect, useState } from "react";
import "./shims/ObjectWatchShim";
/**
 * A React hook that watches for changes to specific properties of an object.
 * When the watched properties change, it triggers a re-render.
 */
export default function useObserve(toObserve, keysToObserve) {
    const [_, ss] = useState(0);
    useLayoutEffect(() => {
        const arr = Array.isArray(toObserve) ? toObserve : [toObserve];
        const unwatchers = arr.map(object => object.watch(keysToObserve, () => {
            ss((p) => {
                return p + 1;
            });
        }));
        return () => unwatchers.forEach(unwatch => unwatch());
    }, [toObserve]);
}
//# sourceMappingURL=useObserve.js.map