Is it possible to modify a mutable variable (cell value) by name? (reflection, introspection, runtime)

i would like to use notebooks as dashboards that receive data via websocket. so in my local development tool i send data to the notebook like so:

socketserver.send “a” 72

this should then modify the value of the cell named “a” (presumably that must be declared as mutable). I can do this with dispatching the variable names and write specific update statements, but I would like to accomplish this generic. by implanting my generic Websocket code I could then remote control the notebook.

The best example about the required introspection I found is the notebook viewer. That notebook hosts its own the runtime and gets access to the “interior” or reflected view of the notebook. I think I cannot use that approach, as I want to modify variable in the current notebook. And since cell functions are evaluated inside isolated workers I guess I cannot update named cells via reflection.

Or is that possible?

There’s no generic ability to set the value of another cell, but you can define a cell that represents all the values that the socket can send and react to that, or you can define separate cells that share a socket and update independently.

Here’s an example of the single cell approach to define realtime data:

And here’s an example of cells that update independently by share the same socket:

I’d consider the later primarily for performance reasons, if you want downstream cells to react only to the subset of the realtime data they care about.

thank you for your help and hints mike.

i see you just wrote the socket sharing nb, thanks, will continue with that approach.