Memoise selection of nodes
Summary: For the visualiser we use the same trick as with the hover state. We subscribe to selection changes and only render if the prev or new state concerns us. For the tree we change from object identity to the node id + and indent guide are added to the memoisation equal check. Depending on teh change this tree memoisation can vary in effectiveness. If you go from nothing selecting to selecting the top element nothing is memoised since react needs to render every element to draw the indent guide. If you have somethign selected and select a nearby element the memoisation works well. There are ways to improve this more down the road changelog: UIDebugger improve performance of selecting nodes Reviewed By: lblasa Differential Revision: D43305979 fbshipit-source-id: 5d90e806ed7b6a8401e9968be398d4a67ed0c294
This commit is contained in:
committed by
Facebook GitHub Bot
parent
786ae04d21
commit
8581aa1944
@@ -39,6 +39,7 @@ type UIState = {
|
||||
searchTerm: Atom<string>;
|
||||
isContextMenuOpen: Atom<boolean>;
|
||||
hoveredNodes: Atom<Id[]>;
|
||||
selectedNode: Atom<Id | undefined>;
|
||||
highlightedNodes: Atom<Set<Id>>;
|
||||
focusedNode: Atom<Id | undefined>;
|
||||
expandedNodes: Atom<Set<Id>>;
|
||||
@@ -92,6 +93,7 @@ export function plugin(client: PluginClient<Events>) {
|
||||
|
||||
highlightedNodes,
|
||||
|
||||
selectedNode: createState<Id | undefined>(undefined),
|
||||
//used to indicate whether we will higher the visualizer / tree when a matching event comes in
|
||||
//also whether or not will show running total in the tree
|
||||
frameworkEventMonitoring: createState(
|
||||
@@ -255,6 +257,7 @@ type UIActions = {
|
||||
onHoverNode: (node: Id) => void;
|
||||
onFocusNode: (focused?: Id) => void;
|
||||
onContextMenuOpen: (open: boolean) => void;
|
||||
onSelectNode: (node?: Id) => void;
|
||||
onExpandNode: (node: Id) => void;
|
||||
onCollapseNode: (node: Id) => void;
|
||||
};
|
||||
@@ -265,6 +268,9 @@ function uiActions(uiState: UIState): UIActions {
|
||||
draft.add(node);
|
||||
});
|
||||
};
|
||||
const onSelectNode = (node?: Id) => {
|
||||
uiState.selectedNode.set(node);
|
||||
};
|
||||
|
||||
const onCollapseNode = (node: Id) => {
|
||||
uiState.expandedNodes.update((draft) => {
|
||||
@@ -288,6 +294,7 @@ function uiActions(uiState: UIState): UIActions {
|
||||
onExpandNode,
|
||||
onCollapseNode,
|
||||
onHoverNode,
|
||||
onSelectNode,
|
||||
onContextMenuOpen,
|
||||
onFocusNode,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user