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

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more