ref(speaker-stats): begin polling for stats after mount

This commit is contained in:
Leonard Kim 2018-10-28 19:10:47 -07:00 committed by Leonard Kim
parent 007d60eb6c
commit 1e3e71c2ff
1 changed files with 8 additions and 11 deletions

View File

@ -12,7 +12,7 @@ import SpeakerStatsLabels from './SpeakerStatsLabels';
declare var interfaceConfig: Object;
/**
* The type of the React {@code Component} props of {@link SpeakerStats}
* The type of the React {@code Component} props of {@link SpeakerStats}.
*/
type Props = {
@ -33,7 +33,7 @@ type Props = {
};
/**
* The type of the React {@code Component} state of {@link SpeakerStats}
* The type of the React {@code Component} state of {@link SpeakerStats}.
*/
type State = {
@ -49,10 +49,6 @@ type State = {
* @extends Component
*/
class SpeakerStats extends Component<Props, State> {
state = {
stats: {}
};
_updateInterval: IntervalID;
/**
@ -64,19 +60,20 @@ class SpeakerStats extends Component<Props, State> {
constructor(props) {
super(props);
this.state = {
stats: this.props.conference.getSpeakerStats()
};
// Bind event handlers so they are only bound once per instance.
this._updateStats = this._updateStats.bind(this);
}
/**
* Immediately request for updated speaker stats and begin
* polling for speaker stats updates.
* Begin polling for speaker stats updates.
*
* @inheritdoc
* @returns {void}
*/
componentWillMount() {
this._updateStats();
componentDidMount() {
this._updateInterval = setInterval(this._updateStats, 1000);
}