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:
committed by
Facebook Github Bot
parent
e1e8760f12
commit
98bc01618f
@@ -19,6 +19,7 @@ import {
|
|||||||
VerticalRule,
|
VerticalRule,
|
||||||
Button,
|
Button,
|
||||||
GK,
|
GK,
|
||||||
|
Idler,
|
||||||
} from 'flipper';
|
} from 'flipper';
|
||||||
import Inspector from './Inspector';
|
import Inspector from './Inspector';
|
||||||
import ToolbarIcon from './ToolbarIcon';
|
import ToolbarIcon from './ToolbarIcon';
|
||||||
@@ -63,6 +64,25 @@ export default class Layout extends FlipperPlugin<State, any, PersistedState> {
|
|||||||
return allNodes;
|
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 = {
|
static defaultPersistedState = {
|
||||||
rootElement: null,
|
rootElement: null,
|
||||||
rootAXElement: null,
|
rootAXElement: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user