Memory management and proxies
Cells are not garbage collected automatically, since the best practice is to
keep a long-running Sheet
for each application.
To delete a cell, use:
sheet.delete(cell);
To simplify these operations, you can define a sub-graph of cells in a Proxy
that can be deleted at once.
import { SheetProxy } from "@okcontract/cells";
// create a proxy (for instance in a Svelte component)
const proxy = new SheetProxy(sheet);
// use the proxy to create new cells...
const cell = proxy.new(1);
// ...and mapped cells
const mappedCell = proxy.map([...cells], (...args)=>{...})
// delete the proxy when you're done
proxy.destroy();
There are added benefits of proxies, including a single call to wait for all
cells in a Proxy
to be computed.
await proxy.working.wait();