UNPKG

vue-hooks-plus

Version:
19 lines (18 loc) 537 B
import { ref } from "vue"; import isEqual from "lodash-es/isEqual"; import useEffectWithTarget from "./useEffectWithTarget"; const depsEqual = (aDeps, bDeps = []) => { return isEqual(aDeps, bDeps); }; const useDeepCompareEffectWithTarget = (effect, deps, target) => { const targetRef = ref(); const signalRef = ref(0); if (!depsEqual(deps, targetRef.value)) { targetRef.value = deps; signalRef.value += 1; } useEffectWithTarget(effect, [signalRef], target); }; export { useDeepCompareEffectWithTarget as default };