Make sure Sandy plugis can be initialized
Summary:
This diff makes sure sandy plugins are initialized.
Sandy plugins are stored directly in the client for two reasons
1. we want to decouple any plugin state updates from our central redux store, as redux is particularly bad in handling high frequency updates.
2. The lifecycle of a plugin is now bound to the lifecycle of a client. This means that we don't need 'persistedStore' to make sure state is preserved; that is now the default. Switching plugins will no longer reinitialize them (but only run specific hooks, see later diffs).
3. PersistedState will be introduced for sandy plugins as well later, but primarily for import / export / debug reasons.
A significant difference with the current persistent state, is that if a client crashes and reconnects, plugins will loose their state. We can prevent this (again, since state persisting will be reintroduced), but I'm not sure we need that for the specific reconnect scenario. Because
1. we should fix reconnecting clients anyway, and from stats it looks to happen less already
2. reconnects are usually caused by plugins that aggregate a lot of data and get slower over time. Restoring old state also restores those unstabilites.
For the overview bringing back the archi picture of earlier diff:
{F241508042}
Also fixed a bug where enabling background plugins didn't enable them on all devices with that app.
Reviewed By: jknoxville
Differential Revision: D22186276
fbshipit-source-id: 3fd42b577f86920e5280aa8cce1a0bc4d5564ed9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bf79c9472e
commit
1dc9e899b8
@@ -42,25 +42,40 @@ export type FlipperPluginModule = {
|
||||
// devicePlugin: FlipperPluginFactory
|
||||
};
|
||||
|
||||
export class FlipperPluginInstance {
|
||||
export class SandyPluginInstance {
|
||||
/** base client provided by Flipper */
|
||||
realClient: RealFlipperClient;
|
||||
/** client that is bound to this instance */
|
||||
client: FlipperClient<any, any>;
|
||||
/** the original plugin definition */
|
||||
definition: FlipperPluginModule;
|
||||
definition: SandyPluginDefinition;
|
||||
/** the plugin instance api as used inside components and such */
|
||||
instanceApi: object;
|
||||
|
||||
constructor(realClient: RealFlipperClient, definition: FlipperPluginModule) {
|
||||
constructor(
|
||||
realClient: RealFlipperClient,
|
||||
definition: SandyPluginDefinition,
|
||||
) {
|
||||
this.realClient = realClient;
|
||||
this.definition = definition;
|
||||
this.client = {};
|
||||
this.instanceApi = definition.plugin(this.client);
|
||||
this.instanceApi = definition.module.plugin(this.client);
|
||||
}
|
||||
|
||||
activate() {
|
||||
// TODO: T68683507
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
// TODO:
|
||||
// TODO: T68683507
|
||||
}
|
||||
|
||||
destroy() {
|
||||
// TODO: T68683507
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
// TODO: T68683449
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user