Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize views in Observable #540

Open
domoritz opened this issue Aug 19, 2020 · 0 comments
Open

Finalize views in Observable #540

domoritz opened this issue Aug 19, 2020 · 0 comments

Comments

@domoritz
Copy link
Member

domoritz commented Aug 19, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@domoritz and others