-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Suggestion] Collapse chart node by default if children > 5 #233
Comments
@kevinlaw91, thanks for the suggestion. I see why you want this.
|
Now it's possible to navigate only a subtree (see the release notes). However, setting a threshold would be still useful. If you want to fix that issue in |
Having this option should would be great: We're working with large arrays in our store, that perform fine, but cause the dev tools to lag a lot. This is made worse by the fact that we're also dealing with audio data; the dev tools chart just becomes unusable as it tries to chart a UInt8 array with 20960 entries, when we don't ever actually need to see that bit of information. Having the dev tools collapse everything by default would be a nice immediate fix, but the ability to customise the number of nodes for triggering auto collapsing would be a fantastic addition. I can also think of a couple of extra additions that would help with this problem, such as having objects in arrays collapsed by default (as it's very common on our project to be interested in a single user out of a 100, that are stored in a map that has the users id as the key). Another possible cool feature would a I've just implemented a custom For example, You could utilize this code in dev tools to allow targeted collapsing: By providing an array of "property chain" strings to Let me know if you're interested @zalmoxisus and I'll chuck the |
I ran into this as well... it's really hard to navigate large state trees. Even just having a command to collapse all the nodes would be really helpful. |
Our application had a map of users ( Here's a simplified slice of how our state looked:
This made the devtools pretty unusable, since the average speech property would have something like 1000 elements to it, that the devtools would try to render. Since we didn't actually need to the speech the property in that part of the state (doubly so when working in development), I built a custom Currently it exploits the fact that objects are passed by reference to clear properties on the state, but I feel it should be pretty straightforward to utilize this into devtools as a means of calculating which state properties to collapse by default in a manner that makes it super easy for us developers to configure. Here is what the property path string looks like to target the annoying (You can easily get the path property of a property via the Chrome console - More on this at the end). Here is the
Note that I'm going to focus mainly on the function inside of the The The first part takes a string (in classic dot notation format), while the second part takes an array. The second part (which I refer to as the Once we've got the reference to that parent object, we can simply assign an empty string to it, and all is well. The actual code here is boring; The main important thing about the Actioner is that it takes an array of strings looking like this: that it uses to get to the property it needs to action. This is the part in devtools that would handle doing the actual collapsing; the cooler part is how those string arrays are built, since we want to support targeting properties that are stored inside arrays and maps without having to explicitly define the property accessors. And that is exactly what we do in the first part of the sanitizer (which I refer to as the The Expander takes a string that describes (using dot notation) the names of the properties that should be traversed in order to reach the desired target property on the state. The Expander 'expands' a given string in an array of arrays (with the elements of the array being the names of the properties that should be traversed in order to reach the desired target property on the state - sound familiar?). It does this by splitting the given string into an array of properties based on the position of the dot character ( As it iterates, the Expander tests the current property with the chain being built against the state: if it can't access a property at any point, it throws out the chain (meaning that you don't have to worry about errors arising by non-existing properties on the state). The other thing the Expander does is handle maps & arrays. If the Expander encounters a substring with the value This works because as the Expander iterators over the properties, it adds those property names to each existing chain in the Once the Expander has finished, each array in the Heres an example: Given the state I give at the start, we could target the speech property with the given string: This string is split: It's then passed to the expander, which generates the following:
(Note and ignore the empty array - it's there as a result because the Expander can't pop out a 'broken' chain while it's iterating over chains, as that would be a concurrent modification. There's really no point in bothering to filter them out, when instead the Actioner can just check that a chain has a length before bothering to try and follow the chain). Each one of these are passed to the Actioner, which then sets all the speech properties to an empty string. Last-minute notes:
Hopefully the above makes sense - I spent a bit of time on that explanation, so I welcome feedback :) I'd be very keen to see this implemented into the devtools, as I think it would be a really powerful feature. I'm happy to take a crack at it myself - I suspect it'll either be very easy or very hard to implement the above code, as it depends a lot on when, where and how the devtools handles collapsing of elements. Either Way, hopefully the above is useful for someone out there. Finally: The Chrome Console can provide you with property paths that you can use with this. All you do is just right click on a property of an object outputted by the console - simple. You can try it out by just copying the state example I gave at the start of the comment, paste it into the chrome console, expand the output and then right click on any property and click 'copy property path'. The only thing you have to do is to replace any array and object property accessors with For example, with the state object from the start, Chrome will give Let know what you think of all this @zalmoxisus - I'm interested in hearing your thoughts :) |
Commenting to +1 this suggestion. Would be wildly helpful for viewing a more normalized state. |
+1 here! This would still be really useful to me, and make navigating a state involving long arrays significantly easier and less frustrating! |
This will make the chart easier to navigate and read. Better if we can set the threshold in devtools options too.
The text was updated successfully, but these errors were encountered: