Throttle chart updates

This commit is contained in:
Thomas Nordquist
2019-06-16 22:42:17 +02:00
parent 486a3568e9
commit eaafb68117

View File

@@ -8,7 +8,8 @@ import { bindActionCreators } from 'redux'
import { chartActions } from '../../actions' import { chartActions } from '../../actions'
import { ChartParameters } from '../../reducers/Charts' import { ChartParameters } from '../../reducers/Charts'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { Paper, Theme, Typography, withStyles, Fade } from '@material-ui/core' import { Fade, Paper, Theme, Typography, withStyles } from '@material-ui/core'
const throttle = require('lodash.throttle')
interface Props { interface Props {
parameters: ChartParameters parameters: ChartParameters
@@ -31,7 +32,7 @@ function Chart(props: Props) {
/** If a node is not available when the plot is shown, keep polling until it has been created */ /** If a node is not available when the plot is shown, keep polling until it has been created */
function pollForTreeNode() { function pollForTreeNode() {
const onUpdateCallback = () => setLastUpdate(treeNode ? treeNode.lastUpdate : 0) const onUpdateCallback = throttle(() => setLastUpdate(treeNode ? treeNode.lastUpdate : 0), 300)
let intervalTimer: any let intervalTimer: any
if (!treeNode) { if (!treeNode) {