* Enhancement Akryum#453 Reactive pollInterval. * Small change for pollInterval enhancement #453 * Remove unnecessary if-check in pollIntervalChanged
This commit is contained in:
committed by
Guillaume Chau
parent
54ed6254a3
commit
51590c83fe
@@ -10,6 +10,7 @@ export default class SmartApollo {
|
||||
this.initialOptions = options
|
||||
this.options = Object.assign({}, options)
|
||||
this._skip = false
|
||||
this._pollInterval = null
|
||||
this._watchers = []
|
||||
this._destroyed = false
|
||||
|
||||
@@ -29,6 +30,22 @@ export default class SmartApollo {
|
||||
} else {
|
||||
this._skip = true
|
||||
}
|
||||
|
||||
if(typeof this.options.pollInterval === 'function') {
|
||||
this._pollWatcher = this.vm.$watch(this.options.pollInterval.bind(this.vm),this.pollIntervalChanged.bind(this), {immediate:true})
|
||||
}
|
||||
}
|
||||
|
||||
pollIntervalChanged (value, oldValue) {
|
||||
if (value !== oldValue) {
|
||||
this.pollInterval = value
|
||||
|
||||
if(value == null) {
|
||||
this.stopPolling()
|
||||
} else {
|
||||
this.startPolling(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skipChanged (value, oldValue) {
|
||||
@@ -37,6 +54,14 @@ export default class SmartApollo {
|
||||
}
|
||||
}
|
||||
|
||||
get pollInterval() {
|
||||
return this._pollInterval
|
||||
}
|
||||
|
||||
set pollInterval(value) {
|
||||
this._pollInterval = value
|
||||
}
|
||||
|
||||
get skip () {
|
||||
return this._skip
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user