Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/smart-apollo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) {
Expand All @@ -37,6 +54,14 @@ export default class SmartApollo {
}
}

get pollInterval() {
return this._pollInterval
}

set pollInterval(value) {
this._pollInterval = value
}

get skip () {
return this._skip
}
Expand Down