Skip to content

Commit

Permalink
fix: start polling stats on window show to avoid delay (#537)
Browse files Browse the repository at this point in the history
* fix: start polling stats on window show to avoid delay

* remove trailing whitespace
  • Loading branch information
hacdias authored and daviddias committed Dec 7, 2017
1 parent 58b6d44 commit 567e634
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/utils/stats-poller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ export default class StatsPoller extends EventEmitter {
this.shouldPoll = false
this.statsCache = {}
this.locationsCache = {}

this._poller()
}

_poller () {
const next = () => setTimeout(() => this._poller(), 1000)

if (!this.shouldPoll) {
return next()
return
}

this.ipfs.swarm.peers()
Expand Down Expand Up @@ -87,5 +85,6 @@ export default class StatsPoller extends EventEmitter {

start () {
this.shouldPoll = true
this._poller()
}
}

0 comments on commit 567e634

Please sign in to comment.