From db5de7d3ad9787cd073b06a42d53dd398cc37268 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 5 Mar 2016 20:07:51 -0800 Subject: [PATCH] one less global --- renderer/index.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/renderer/index.js b/renderer/index.js index 691e23da..f2709dc1 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -31,16 +31,14 @@ global.WEBTORRENT_ANNOUNCE = createTorrent.announceList return url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0 }) -var client, vdomLoop, updateThrottled +var vdomLoop, updateThrottled function init () { - client = new WebTorrent() - client.on('warning', onWarning) - client.on('error', onError) - state.client = client + state.client = new WebTorrent() + state.client.on('warning', onWarning) + state.client.on('error', onError) // For easy debugging in Developer Tools - global.client = client global.state = state vdomLoop = mainLoop(state, render, { @@ -207,13 +205,13 @@ function isNotTorrentFile (file) { function addTorrent (torrentId) { if (!torrentId) torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4' - var torrent = client.add(torrentId) + var torrent = state.client.add(torrentId) addTorrentEvents(torrent) } function seed (files) { if (files.length === 0) return - var torrent = client.seed(files) + var torrent = state.client.seed(files) addTorrentEvents(torrent) }