@aplus-frontend/antdv
Version:
Vue basic component library maintained based on ant-design-vue
20 lines (19 loc) • 466 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useMemo;
var _vue = require("vue");
function useMemo(getValue, condition, shouldUpdate) {
const cacheRef = (0, _vue.ref)(getValue());
(0, _vue.watch)(condition, (next, pre) => {
if (shouldUpdate) {
if (shouldUpdate(next, pre)) {
cacheRef.value = getValue();
}
} else {
cacheRef.value = getValue();
}
});
return cacheRef;
}
;