Should there be an example for .finalize() + invalidation? It would seem that cleaning up after a view is especially important in the context of Observable, where cells can be rebuilt rather frequently.
In each cell you have access to an "invalidation" promise that resolves when the cell is updated. To give a code example:
invalidation.then(() => view.finalize());
where view is the return value of the resolved promise that is returned by embed. The snippet is taken from https://observablehq.com/@mootari/optimal-tiling#view
More details about invalidation can be found at https://observablehq.com/@observablehq/invalidation