-
-
Notifications
You must be signed in to change notification settings - Fork 984
Description
I thought I'd write this up since it's one of many things I'd like to do here and like most tertiary things I have no experience with. I was looking into options for Dev Tools for Solid and I realized that it doesn't particularly make sense to have the same sort of tools as React as the Components are ephemeral. Visualizing a virtual tree as rendered in the DOM is not as valuable as visualizing the data. So I was thinking how to visual Solid's Reactive Graph and what it would look like. Solid actually has 2 graphs sitting on top of each other. The dependency graph and the structural graph.
-
The dependency graph is the one we are more accustomed to. The one that we've in MobX articles or visualizations for reactive programming. CycleJS and RxJS have done a good job of showing the visuals for data streams. This is more recognizing how change propagates. So if you change one Signal, the computations that track it also re-evaluate, and the ones that track those (if it's a memo) also track it. The characteristic in Solid though that might make this different is generally this graph is pretty shallow since we avoid unnecessary reactive wrappers. And it isn't so much a single graph but clusters or groupings of signals across different computations. This visual would be really useful when tracking fine details but it would be difficult perhaps to see your app from this view.
-
The structural graph is more like the graph one might find in Redux dev tools. It is more of a tree where there is a Root, and each child Computation holds each of its children all the way down. When I say children I don't mean things it depends on but rather computations that were created in executing it's context. Ie.. things that would be destroyed if ever re-evaluated (other than sub-roots). What we could see here are those child computations, any registered cleanup methods.
So the trick here is putting the two together I think. If we walk the structural graph we could at any point traverse into the dependency graph to see that computations dependencies. It would be interesting to see how writing a certain signal can trigger computations that change the shape of the structural graph. But you'd almost need to link back to lines in the JavaScript source for computation re-evaluation to have much value here. It would be interesting if we could use this as a way of highlighting the currently executing reactive scope and to set breakpoints, and from there using Source maps to take us back into our Component code.
Unfortunately I don't believe anyone has done anything like this before. Or atleast I haven't come across it. But it would be a really sweet addition to libraries like this. Not only for debugging and performance optimization, but for visualization for learning. Anyway thought I'd throw this out there.