Public
Edited
Oct 5, 2023
Insert cell
Insert cell
refunc = import("https://cdn.skypack.dev/@engraft/refunc@0.0.1")
Insert cell
refunc2 = import("https://esm.sh/@engraft/refunc@0.0.1")
Insert cell
square = refunc.hooks((x) => {
const squared = refunc.hookMemo(() => {
console.log('squaring', x)
return x * x;
}, [x]);
return squared;
});
Insert cell
{
var mem = new refunc.RefuncMemory();
console.log(square(mem, 3));
// → squaring 3
// → 9
console.log(square(mem, 3));
// → 9
console.log(square(mem, 4));
// → squaring 4
// → 16
console.log(square(mem, 4));
// → 16
// But note that we only remember the very
// latest input:
console.log(square(mem, 3));
// → squaring 3
// → 9
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more