Rename AutoRefresh util to AutoRefresher
So as not to be confused with `autoRefresh` props, which are of type number.pull/4297/head
parent
ef9fc85654
commit
1e8088d60d
|
@ -37,7 +37,7 @@ import idNormalizer, {TYPE_ID} from 'src/normalizers/id'
|
|||
import {millisecondTimeRange} from 'src/dashboards/utils/time'
|
||||
import {getDeep} from 'src/utils/wrappers'
|
||||
import {updateDashboardLinks} from 'src/dashboards/utils/dashboardSwitcherLinks'
|
||||
import {GlobalAutoRefresh} from 'src/utils/AutoRefresh'
|
||||
import {GlobalAutoRefresher} from 'src/utils/AutoRefresher'
|
||||
|
||||
// APIs
|
||||
import {loadDashboardLinks} from 'src/dashboards/apis'
|
||||
|
@ -179,8 +179,8 @@ class DashboardPage extends Component<Props, State> {
|
|||
public async componentDidMount() {
|
||||
const {autoRefresh} = this.props
|
||||
|
||||
GlobalAutoRefresh.poll(autoRefresh)
|
||||
GlobalAutoRefresh.subscribe(this.fetchAnnotations)
|
||||
GlobalAutoRefresher.poll(autoRefresh)
|
||||
GlobalAutoRefresher.subscribe(this.fetchAnnotations)
|
||||
|
||||
window.addEventListener('resize', this.handleWindowResize, true)
|
||||
|
||||
|
@ -214,7 +214,7 @@ class DashboardPage extends Component<Props, State> {
|
|||
}
|
||||
|
||||
if (autoRefresh !== prevProps.autoRefresh) {
|
||||
GlobalAutoRefresh.poll(autoRefresh)
|
||||
GlobalAutoRefresher.poll(autoRefresh)
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -226,8 +226,8 @@ class DashboardPage extends Component<Props, State> {
|
|||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
GlobalAutoRefresh.stopPolling()
|
||||
GlobalAutoRefresh.unsubscribe(this.fetchAnnotations)
|
||||
GlobalAutoRefresher.stopPolling()
|
||||
GlobalAutoRefresher.unsubscribe(this.fetchAnnotations)
|
||||
|
||||
window.removeEventListener('resize', this.handleWindowResize, true)
|
||||
this.props.handleDismissEditingAnnotation()
|
||||
|
|
|
@ -9,7 +9,7 @@ import _ from 'lodash'
|
|||
|
||||
// Utils
|
||||
import {stripPrefix} from 'src/utils/basepath'
|
||||
import {GlobalAutoRefresh} from 'src/utils/AutoRefresh'
|
||||
import {GlobalAutoRefresher} from 'src/utils/AutoRefresher'
|
||||
|
||||
// Components
|
||||
import QueryMaker from 'src/data_explorer/components/QueryMaker'
|
||||
|
@ -82,7 +82,7 @@ export class DataExplorer extends PureComponent<Props, State> {
|
|||
await handleGetDashboards()
|
||||
}
|
||||
|
||||
GlobalAutoRefresh.poll(autoRefresh)
|
||||
GlobalAutoRefresher.poll(autoRefresh)
|
||||
|
||||
if (query && query.length) {
|
||||
const qc = this.props.queryConfigs[0]
|
||||
|
@ -97,7 +97,7 @@ export class DataExplorer extends PureComponent<Props, State> {
|
|||
public componentDidUpdate(prevProps: Props) {
|
||||
const {autoRefresh} = this.props
|
||||
if (autoRefresh !== prevProps.autoRefresh) {
|
||||
GlobalAutoRefresh.poll(autoRefresh)
|
||||
GlobalAutoRefresher.poll(autoRefresh)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ export class DataExplorer extends PureComponent<Props, State> {
|
|||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
GlobalAutoRefresh.stopPolling()
|
||||
GlobalAutoRefresher.stopPolling()
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
|
|
@ -20,7 +20,7 @@ import {EMPTY_LINKS} from 'src/dashboards/constants/dashboardHeader'
|
|||
|
||||
import {setAutoRefresh, delayEnablePresentationMode} from 'shared/actions/app'
|
||||
import {ErrorHandling} from 'src/shared/decorators/errors'
|
||||
import {GlobalAutoRefresh} from 'src/utils/AutoRefresh'
|
||||
import {GlobalAutoRefresher} from 'src/utils/AutoRefresher'
|
||||
|
||||
@ErrorHandling
|
||||
class HostPage extends Component {
|
||||
|
@ -55,7 +55,7 @@ class HostPage extends Component {
|
|||
} = await getLayouts()
|
||||
const {location, autoRefresh} = this.props
|
||||
|
||||
GlobalAutoRefresh.poll(autoRefresh)
|
||||
GlobalAutoRefresher.poll(autoRefresh)
|
||||
|
||||
// fetching layouts and mappings can be done at the same time
|
||||
const {host, measurements} = await this.fetchHostsAndMeasurements(layouts)
|
||||
|
@ -82,12 +82,12 @@ class HostPage extends Component {
|
|||
componentDidUpdate(prevProps) {
|
||||
const {autoRefresh} = this.props
|
||||
if (prevProps.autoRefresh !== autoRefresh) {
|
||||
GlobalAutoRefresh.poll(autoRefresh)
|
||||
GlobalAutoRefresher.poll(autoRefresh)
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
GlobalAutoRefresh.stopPolling()
|
||||
GlobalAutoRefresher.stopPolling()
|
||||
}
|
||||
|
||||
handleChooseTimeRange = ({lower, upper}) => {
|
||||
|
|
|
@ -19,7 +19,7 @@ import {TimeSeriesServerResponse, TimeSeriesResponse} from 'src/types/series'
|
|||
import {GrabDataForDownloadHandler} from 'src/types/layout'
|
||||
|
||||
// Utils
|
||||
import {GlobalAutoRefresh, AutoRefresh} from 'src/utils/AutoRefresh'
|
||||
import {GlobalAutoRefresher, AutoRefresher} from 'src/utils/AutoRefresher'
|
||||
import {CellNoteVisibility} from 'src/types/dashboards'
|
||||
|
||||
// Components
|
||||
|
@ -39,7 +39,7 @@ interface Props {
|
|||
queries: Query[]
|
||||
timeRange: TimeRange
|
||||
children: (r: RenderProps) => JSX.Element
|
||||
autoRefresh?: AutoRefresh
|
||||
autoRefresher?: AutoRefresher
|
||||
inView?: boolean
|
||||
templates?: Template[]
|
||||
editQueryStatus?: () => void
|
||||
|
@ -67,7 +67,7 @@ class TimeSeries extends Component<Props, State> {
|
|||
public static defaultProps = {
|
||||
inView: true,
|
||||
templates: [],
|
||||
autoRefresh: GlobalAutoRefresh,
|
||||
autoRefresher: GlobalAutoRefresher,
|
||||
}
|
||||
|
||||
public static getDerivedStateFromProps(props: Props, state: State) {
|
||||
|
@ -119,24 +119,24 @@ class TimeSeries extends Component<Props, State> {
|
|||
}
|
||||
|
||||
public async componentDidMount() {
|
||||
const {autoRefresh} = this.props
|
||||
const {autoRefresher} = this.props
|
||||
|
||||
this.isComponentMounted = true
|
||||
this.executeQueries()
|
||||
autoRefresh.subscribe(this.executeQueries)
|
||||
autoRefresher.subscribe(this.executeQueries)
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
const {autoRefresh} = this.props
|
||||
const {autoRefresher} = this.props
|
||||
|
||||
this.isComponentMounted = false
|
||||
autoRefresh.unsubscribe(this.executeQueries)
|
||||
autoRefresher.unsubscribe(this.executeQueries)
|
||||
}
|
||||
|
||||
public async componentDidUpdate(prevProps: Props) {
|
||||
if (this.props.autoRefresh !== prevProps.autoRefresh) {
|
||||
prevProps.autoRefresh.unsubscribe(this.executeQueries)
|
||||
this.props.autoRefresh.subscribe(this.executeQueries)
|
||||
if (this.props.autoRefresher !== prevProps.autoRefresher) {
|
||||
prevProps.autoRefresher.unsubscribe(this.executeQueries)
|
||||
this.props.autoRefresher.subscribe(this.executeQueries)
|
||||
}
|
||||
|
||||
if (!this.isPropsDifferent(prevProps)) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
type func = (...args: any[]) => any
|
||||
|
||||
export class AutoRefresh {
|
||||
export class AutoRefresher {
|
||||
public subscribers: func[] = []
|
||||
|
||||
private intervalID: NodeJS.Timer
|
||||
|
@ -39,7 +39,7 @@ export class AutoRefresh {
|
|||
}
|
||||
}
|
||||
|
||||
// A global singleton, intended to be configured (via `AutoRefresh#poll`) at a
|
||||
// page level and consumed arbitrarily deep within the page's render tree
|
||||
// A global singleton, intended to be configured (via `AutoRefresher#poll`) at
|
||||
// a page level and consumed arbitrarily deep within the page's render tree
|
||||
// (usually in a `TimeSeries` component)
|
||||
export const GlobalAutoRefresh = new AutoRefresh()
|
||||
export const GlobalAutoRefresher = new AutoRefresher()
|
Loading…
Reference in New Issue