Flatten layout during traversal
Summary: Move from a nested structure to a flatten one for data exchange, this will allow us to only send sections of the UI in the future Reviewed By: lblasa Differential Revision: D38982138 fbshipit-source-id: d578a07a6d2d7e117fbd741bd6e33062223ce10d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
55b852f90c
commit
a5da6923eb
@@ -43,26 +43,26 @@ export type UINode = {
|
||||
id: Id;
|
||||
name: string;
|
||||
attributes: Record<string, Inspectable>;
|
||||
children: UINode[];
|
||||
children: Id[];
|
||||
};
|
||||
|
||||
type Events = {
|
||||
init: {rootId: string};
|
||||
|
||||
nativeScan: {root: UINode};
|
||||
nativeScan: {nodes: UINode[]};
|
||||
};
|
||||
|
||||
export function plugin(client: PluginClient<Events>) {
|
||||
const rootId = createState<string | undefined>(undefined);
|
||||
const rootId = createState<Id | undefined>(undefined);
|
||||
|
||||
const tree = createState<UINode | undefined>(undefined);
|
||||
const nodesAtom = createState<Map<Id, UINode>>(new Map());
|
||||
client.onMessage('init', (root) => rootId.set(root.rootId));
|
||||
|
||||
client.onMessage('nativeScan', ({root}) => {
|
||||
tree.set(root as UINode);
|
||||
client.onMessage('nativeScan', ({nodes}) => {
|
||||
nodesAtom.set(new Map(nodes.map((node) => [node.id, node])));
|
||||
console.log(nodesAtom.get());
|
||||
});
|
||||
|
||||
return {rootId, tree};
|
||||
return {rootId, nodes: nodesAtom};
|
||||
}
|
||||
|
||||
export {Component} from './components/main';
|
||||
|
||||
Reference in New Issue
Block a user