Properly wait 1 second between runs of adb b2g-info
Summary: This slows down the phone less. In the future, it'd be nice to get timestamp on X axis. Reviewed By: passy Differential Revision: D19097154 fbshipit-source-id: e145f1b911dec368a6bb7de32790d6280c696eda
This commit is contained in:
committed by
Facebook Github Bot
parent
7af8e2d5a3
commit
294a400428
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import {FlipperDevicePlugin, Device, KaiOSDevice} from 'flipper';
|
import {FlipperDevicePlugin, Device, KaiOSDevice, sleep} from 'flipper';
|
||||||
|
|
||||||
import {FlexColumn, Button, Toolbar, Panel} from 'flipper';
|
import {FlexColumn, Button, Toolbar, Panel} from 'flipper';
|
||||||
|
|
||||||
@@ -74,33 +74,36 @@ export default class KaiOSGraphs extends FlipperDevicePlugin<State, any, any> {
|
|||||||
monitoring: false,
|
monitoring: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
intervalID: NodeJS.Timer | null = null;
|
|
||||||
|
|
||||||
static supportsDevice(device: Device) {
|
static supportsDevice(device: Device) {
|
||||||
return device instanceof KaiOSDevice;
|
return device instanceof KaiOSDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
this.onStopMonitor();
|
||||||
|
}
|
||||||
|
|
||||||
onStartMonitor = () => {
|
onStartMonitor = () => {
|
||||||
if (this.intervalID) {
|
this.setState(
|
||||||
return;
|
{
|
||||||
}
|
monitoring: true,
|
||||||
|
},
|
||||||
this.intervalID = setInterval(this.updateFreeMem, 1000);
|
() => {
|
||||||
|
// no await because monitoring runs in the background
|
||||||
this.setState({
|
this.monitorInBackground();
|
||||||
monitoring: true,
|
},
|
||||||
});
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
onStopMonitor = () => {
|
onStopMonitor = () => {
|
||||||
if (!this.intervalID) {
|
this.setState({
|
||||||
return;
|
monitoring: false,
|
||||||
} else {
|
});
|
||||||
clearInterval(this.intervalID);
|
};
|
||||||
this.intervalID = null;
|
|
||||||
this.setState({
|
monitorInBackground = async () => {
|
||||||
monitoring: false,
|
while (this.state.monitoring) {
|
||||||
});
|
await this.updateFreeMem();
|
||||||
|
await sleep(1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user