Search code examples
javascriptd3.jspromiseobservablehq

What is "invalidation" in this Observablehq example?


https://observablehq.com/@d3/force-directed-lattice?collection=@d3/d3-drag

there is a line

invalidation.then(() => simulation.stop());

what is this invalidation? by the console.log, it is a promise, but I don't see it defined anywhere.


Solution

  • Observablehq loads the standard library, which provides the invalidation method. According to the documentation, invalidation is...

    A promise that resolves when the current cell is re-evaluated: when the cell’s code changes, when it is run using Shift-Enter, or when a referenced input changes.

    This notebook explains it in details: https://observablehq.com/@observablehq/invalidation