Introduce onConnect / onDisconnect hooks
Summary: Introduced hooks that are called whenever the plugin is connected / disconnected to it's counter part on the device. There is some logic duplication between `PluginContainer` for old plugins, and `PluginRenderer` for new plugins, mostly caused by the fact that those lifecycles are triggered from the UI rather than from the reducers, but I figured refactoring that to be too risky. Reviewed By: jknoxville Differential Revision: D22232337 fbshipit-source-id: a384c45731a4c8d9b8b532a83e2becf49ce807c2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
dd0d957d8b
commit
bde112bf85
@@ -673,13 +673,15 @@ export default class Client extends EventEmitter {
|
||||
initPlugin(pluginId: string) {
|
||||
this.activePlugins.add(pluginId);
|
||||
this.rawSend('init', {plugin: pluginId});
|
||||
// TODO: call sandyOnConnect
|
||||
this.sandyPluginStates.get(pluginId)?.connect();
|
||||
}
|
||||
|
||||
deinitPlugin(pluginId: string) {
|
||||
// TODO: call sandyOnDisconnect
|
||||
this.activePlugins.delete(pluginId);
|
||||
this.rawSend('deinit', {plugin: pluginId});
|
||||
this.sandyPluginStates.get(pluginId)?.disconnect();
|
||||
if (this.connected) {
|
||||
this.rawSend('deinit', {plugin: pluginId});
|
||||
}
|
||||
}
|
||||
|
||||
rawSend(method: string, params?: Object): void {
|
||||
|
||||
Reference in New Issue
Block a user