-
-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Labels
Description
Suggested by @mootari
@mootari
Fabian Iwand
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.
@domoritz
Dominik Moritz
5 hours ago
Yeah, that would be good. I don't know how Observable signals unloading a cell. Do you have a suggestion?
@mootari
Fabian Iwand
1 hour ago
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
Relevant code in https://github.com/vega/vega-embed/blob/master/src/container.ts
Should work in https://observablehq.com/@vega/hello-vega-embed