Fix plugin state serialization
Summary:
Because the recordSourceUpdates where stored in Map instances, they were never serialized when exporting the data to flipper. (JSON.stringify doesn't support Map's). Although Flipper's own serializer does support maps (which is what you get when not overriding these static methods), the Flipper serializer is really slow, which made the export unusable.
~~The reason this became a problem is that in the new message architecture plugin snapshots serialize the events and apply them only when the plugin is opened, rather than doing it immediately when they are received. However, to be able to apply the events, the recordSource should be available. Before this change, this would throw exceptions when viewing the plugin in an imported flipper trace, as this recordSourceUpdates aren't available anymore.~~
The events are processed *before* the export now, so this is no longer a deal breaker, but it is still an improvement, as it will make the data available in the Flipper exports / imports, and fixed the following error that would occur when opening the store page in an flipper import:
{F225365428}
Reviewed By: jonathoma
Differential Revision: D19178158
fbshipit-source-id: f2bc0a05b02dd2fbd1029d472beeb614dded2dd3
This commit is contained in:
committed by
Facebook Github Bot
parent
1f6a344f4d
commit
622d3ee3f0
@@ -138,6 +138,7 @@ export abstract class FlipperBasePlugin<
|
||||
|
||||
// methods to be overriden by plugins
|
||||
init(): void {}
|
||||
|
||||
static serializePersistedState: (
|
||||
persistedState: StaticPersistedState,
|
||||
statusUpdate?: (msg: string) => void,
|
||||
@@ -156,20 +157,25 @@ export abstract class FlipperBasePlugin<
|
||||
pluginName != null ? `Serializing ${pluginName}` : undefined,
|
||||
);
|
||||
};
|
||||
|
||||
static deserializePersistedState: (
|
||||
serializedString: string,
|
||||
) => StaticPersistedState = (serializedString: string) => {
|
||||
return deserialize(serializedString);
|
||||
};
|
||||
|
||||
teardown(): void {}
|
||||
|
||||
computeNotifications(
|
||||
_props: Props<PersistedState>,
|
||||
_state: State,
|
||||
): Array<Notification> {
|
||||
return [];
|
||||
}
|
||||
|
||||
// methods to be overridden by subclasses
|
||||
_init(): void {}
|
||||
|
||||
_teardown(): void {}
|
||||
|
||||
dispatchAction(actionData: Actions) {
|
||||
|
||||
Reference in New Issue
Block a user