import { Ref, ref, watch } from 'vue'; export default function useMemo( getValue: () => T, condition: any[], shouldUpdate: (prev: any[], next: any[]) => boolean, ) { const cacheRef: Ref = ref(getValue() as any); watch(condition, (pre, next) => { if (shouldUpdate(pre, next)) { cacheRef.value = getValue(); } }); return cacheRef; }