observablehq/runtime

Getting the value of a variable with no ID.

GordonSmith opened this issue · 1 comments

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:

  • module(id).value()

Would it be possible to add a

  • variable.value()

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

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.