Override the default serializer for the Layout Plugin

Summary: Overrides the default serializer and deserializer for the Layout Plugin. This diff uses `JSON.stringify` and `JSON.parse` to serialize and deserialize the object respectively. It turns out the our custom serializer is slower than the `JSON.stringify` and the export is way quicker.

Reviewed By: danielbuechele

Differential Revision: D17402443

fbshipit-source-id: 0d36783858ec1972130bdbc57ba7d3cdc5a73774
This commit is contained in:
Pritesh Nandgaonkar
2019-09-17 04:10:36 -07:00
committed by Facebook Github Bot
parent e1e8760f12
commit 98bc01618f

View File

@@ -19,6 +19,7 @@ import {
VerticalRule,
Button,
GK,
Idler,
} from 'flipper';
import Inspector from './Inspector';
import ToolbarIcon from './ToolbarIcon';
@@ -63,6 +64,25 @@ export default class Layout extends FlipperPlugin<State, any, PersistedState> {
return allNodes;
};
static serializePersistedState: (
persistedState: PersistedState,
statusUpdate?: (msg: string) => void,
idler?: Idler,
) => Promise<string> = (
persistedState: PersistedState,
statusUpdate?: (msg: string) => void,
_idler?: Idler,
) => {
statusUpdate && statusUpdate('Serializing Inspector Plugin...');
return Promise.resolve(JSON.stringify(persistedState));
};
static deserializePersistedState: (
serializedString: string,
) => PersistedState = (serializedString: string) => {
return JSON.parse(serializedString);
};
static defaultPersistedState = {
rootElement: null,
rootAXElement: null,