Skip to content

Finalize views in Observable #540

@domoritz

Description

@domoritz

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions