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; 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 = { 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 = { type State = {
@ -49,10 +49,6 @@ type State = {
* @extends Component * @extends Component
*/ */
class SpeakerStats extends Component<Props, State> { class SpeakerStats extends Component<Props, State> {
state = {
stats: {}
};
_updateInterval: IntervalID; _updateInterval: IntervalID;
/** /**
@ -64,19 +60,20 @@ class SpeakerStats extends Component<Props, State> {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {
stats: this.props.conference.getSpeakerStats()
};
// Bind event handlers so they are only bound once per instance. // Bind event handlers so they are only bound once per instance.
this._updateStats = this._updateStats.bind(this); this._updateStats = this._updateStats.bind(this);
} }
/** /**
* Immediately request for updated speaker stats and begin * Begin polling for speaker stats updates.
* polling for speaker stats updates.
* *
* @inheritdoc * @inheritdoc
* @returns {void}
*/ */
componentWillMount() { componentDidMount() {
this._updateStats();
this._updateInterval = setInterval(this._updateStats, 1000); this._updateInterval = setInterval(this._updateStats, 1000);
} }