Apply suggestions from code review
This commit is contained in:
parent
6cb86057c5
commit
e519e704e9
3 changed files with 11 additions and 11 deletions
|
@ -37,13 +37,13 @@ export default class LiveRecordingClock extends React.PureComponent<IProps, ISta
|
||||||
private scheduledUpdate = new MarkedExecution(
|
private scheduledUpdate = new MarkedExecution(
|
||||||
() => this.updateClock(),
|
() => this.updateClock(),
|
||||||
() => requestAnimationFrame(() => this.scheduledUpdate.trigger()),
|
() => requestAnimationFrame(() => this.scheduledUpdate.trigger()),
|
||||||
)
|
);
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
seconds: 0,
|
seconds: 0,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -56,7 +56,7 @@ export default class LiveRecordingClock extends React.PureComponent<IProps, ISta
|
||||||
private updateClock() {
|
private updateClock() {
|
||||||
this.setState({
|
this.setState({
|
||||||
seconds: this.seconds,
|
seconds: this.seconds,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
|
|
@ -25,7 +25,7 @@ interface IProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
waveform: number[]
|
waveform: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,13 +41,13 @@ export default class LiveRecordingWaveform extends React.PureComponent<IProps, I
|
||||||
private scheduledUpdate = new MarkedExecution(
|
private scheduledUpdate = new MarkedExecution(
|
||||||
() => this.updateWaveform(),
|
() => this.updateWaveform(),
|
||||||
() => requestAnimationFrame(() => this.scheduledUpdate.trigger()),
|
() => requestAnimationFrame(() => this.scheduledUpdate.trigger()),
|
||||||
)
|
);
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
waveform: [],
|
waveform: [],
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|
|
@ -22,7 +22,7 @@ limitations under the License.
|
||||||
* The function starts unmarked.
|
* The function starts unmarked.
|
||||||
*/
|
*/
|
||||||
export class MarkedExecution {
|
export class MarkedExecution {
|
||||||
private _marked = false;
|
private marked = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a MarkedExecution for the provided function.
|
* Creates a MarkedExecution for the provided function.
|
||||||
|
@ -37,22 +37,22 @@ export class MarkedExecution {
|
||||||
* Resets the mark without calling the function.
|
* Resets the mark without calling the function.
|
||||||
*/
|
*/
|
||||||
public reset() {
|
public reset() {
|
||||||
this._marked = false;
|
this.marked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the function to be called upon trigger().
|
* Marks the function to be called upon trigger().
|
||||||
*/
|
*/
|
||||||
public mark() {
|
public mark() {
|
||||||
if (!this._marked) this.onMarkCallback?.();
|
if (!this.marked) this.onMarkCallback?.();
|
||||||
this._marked = true;
|
this.marked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If marked, the function will be called, otherwise this does nothing.
|
* If marked, the function will be called, otherwise this does nothing.
|
||||||
*/
|
*/
|
||||||
public trigger() {
|
public trigger() {
|
||||||
if (!this._marked) return;
|
if (!this.marked) return;
|
||||||
this.reset(); // reset first just in case the fn() causes a trigger()
|
this.reset(); // reset first just in case the fn() causes a trigger()
|
||||||
this.fn();
|
this.fn();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue