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 {FlipperDevicePlugin, Device, KaiOSDevice} from 'flipper';
|
||||
import {FlipperDevicePlugin, Device, KaiOSDevice, sleep} from 'flipper';
|
||||
|
||||
import {FlexColumn, Button, Toolbar, Panel} from 'flipper';
|
||||
|
||||
@@ -74,33 +74,36 @@ export default class KaiOSGraphs extends FlipperDevicePlugin<State, any, any> {
|
||||
monitoring: false,
|
||||
};
|
||||
|
||||
intervalID: NodeJS.Timer | null = null;
|
||||
|
||||
static supportsDevice(device: Device) {
|
||||
return device instanceof KaiOSDevice;
|
||||
}
|
||||
|
||||
teardown() {
|
||||
this.onStopMonitor();
|
||||
}
|
||||
|
||||
onStartMonitor = () => {
|
||||
if (this.intervalID) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.intervalID = setInterval(this.updateFreeMem, 1000);
|
||||
|
||||
this.setState({
|
||||
monitoring: true,
|
||||
});
|
||||
this.setState(
|
||||
{
|
||||
monitoring: true,
|
||||
},
|
||||
() => {
|
||||
// no await because monitoring runs in the background
|
||||
this.monitorInBackground();
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
onStopMonitor = () => {
|
||||
if (!this.intervalID) {
|
||||
return;
|
||||
} else {
|
||||
clearInterval(this.intervalID);
|
||||
this.intervalID = null;
|
||||
this.setState({
|
||||
monitoring: false,
|
||||
});
|
||||
this.setState({
|
||||
monitoring: false,
|
||||
});
|
||||
};
|
||||
|
||||
monitorInBackground = async () => {
|
||||
while (this.state.monitoring) {
|
||||
await this.updateFreeMem();
|
||||
await sleep(1000);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user