observablehq / runtime

The reactive dataflow runtime that powers Observable Framework and Observable notebooks
https://observablehq.com/@observablehq/how-observable-runs
ISC License
1.02k stars 72 forks source link

Getting the value of a variable with no ID. #248

Closed GordonSmith closed 3 years ago

GordonSmith commented 4 years ago

I don't believe there is any sane way to get the value of a variable which does not have an ID?

At the moment the API is:

Would it be possible to add a

Method as well?

Why? This will help to keep the VS Code Editor values in sync with the live page values (without adding an extra Inspector callback hook).

image

mbostock commented 3 years ago

There isn’t currently a supported way of doing this, somewhat by design. (We can make stronger assumptions about code being unreachable if unnamed variables cannot be inspected.) That said, we might reconsider this design in the future. There has been internal discussion around using names such as $1, $2, etc. to refer to cells by their automatic identifier rather than names. However, we have no immediate plans to implement this, so I’m closing this issue for now.