Skip to content

Commit

Permalink
Merge pull request #1513 from Chocobozzz/patch-3
Browse files Browse the repository at this point in the history
Try to reduce dl impact on slow computers (web)
  • Loading branch information
DiegoRBaquero committed Sep 28, 2018
2 parents 0f0b10e + 5b7c5ee commit e9b209c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/torrent.js
Expand Up @@ -1138,7 +1138,17 @@ class Torrent extends EventEmitter {
const ite = randomIterate(this.wires)
let wire
while ((wire = ite())) {
this._updateWire(wire)
this._updateWireWrapper(wire)
}
}

_updateWireWrapper (wire) {
const self = this

if (typeof window !== 'undefined' && typeof window.requestIdleCallback === 'function') {
window.requestIdleCallback(function () { self._updateWire(wire) })
} else {
self._updateWire(wire)
}
}

Expand Down

0 comments on commit e9b209c

Please sign in to comment.