Call plugin teardown method when plugin is destroyed

Summary: `teardown()` was not called for device plugins. This diff fixes the issue.

Reviewed By: jknoxville

Differential Revision: D16416440

fbshipit-source-id: 5c9ffa211bfbe4e322504c37b95ff87afab8d061
This commit is contained in:
Zoltán Gilián
2019-07-24 02:59:05 -07:00
committed by Facebook Github Bot
parent a86ea5131c
commit 5beb4f7b2b
2 changed files with 11 additions and 0 deletions

View File

@@ -79,6 +79,13 @@ class PluginContainer extends PureComponent<Props> {
} }
}; };
componentWillUnmount() {
if (this.plugin) {
this.plugin._teardown();
this.plugin = null;
}
}
render() { render() {
const { const {
pluginState, pluginState,

View File

@@ -164,6 +164,10 @@ export class FlipperDevicePlugin<S = *, A = *, P = *> extends FlipperBasePlugin<
this.init(); this.init();
} }
_teardown() {
this.teardown();
}
static supportsDevice(device: BaseDevice) { static supportsDevice(device: BaseDevice) {
throw new Error( throw new Error(
'supportsDevice is unimplemented in FlipperDevicePlugin class', 'supportsDevice is unimplemented in FlipperDevicePlugin class',