on -> once

This commit is contained in:
Feross Aboukhadijeh
2016-06-01 00:10:26 -07:00
parent 8fc61a1c90
commit dac34541d6
4 changed files with 7 additions and 8 deletions

View File

@@ -327,11 +327,11 @@ function buildDarwin (cb) {
} }
var dmg = appDmg(dmgOpts) var dmg = appDmg(dmgOpts)
dmg.on('error', cb) dmg.once('error', cb)
dmg.on('progress', function (info) { dmg.on('progress', function (info) {
if (info.type === 'step-begin') console.log(info.title + '...') if (info.type === 'step-begin') console.log(info.title + '...')
}) })
dmg.on('finish', function (info) { dmg.once('finish', function (info) {
console.log('OS X: Created dmg.') console.log('OS X: Created dmg.')
cb(null) cb(null)
}) })

View File

@@ -55,7 +55,7 @@ function init () {
ipc.init() ipc.init()
app.on('will-finish-launching', function () { app.once('will-finish-launching', function () {
crashReporter.init() crashReporter.init()
}) })
@@ -70,7 +70,7 @@ function init () {
setTimeout(delayedInit, config.DELAYED_INIT) setTimeout(delayedInit, config.DELAYED_INIT)
}) })
app.on('ipcReady', function () { app.once('ipcReady', function () {
log('Command line args:', argv) log('Command line args:', argv)
processArgv(argv) processArgv(argv)
console.timeEnd('init') console.timeEnd('init')
@@ -117,7 +117,6 @@ function onOpen (e, torrentId) {
function onAppOpen (newArgv) { function onAppOpen (newArgv) {
newArgv = sliceArgv(newArgv) newArgv = sliceArgv(newArgv)
console.log(newArgv)
if (app.ipcReady) { if (app.ipcReady) {
log('Second app instance opened, but was prevented:', newArgv) log('Second app instance opened, but was prevented:', newArgv)

View File

@@ -17,7 +17,7 @@ function log (...args) {
if (app.ipcReady) { if (app.ipcReady) {
windows.main.send('log', ...args) windows.main.send('log', ...args)
} else { } else {
app.on('ipcReady', () => windows.main.send('log', ...args)) app.once('ipcReady', () => windows.main.send('log', ...args))
} }
} }
@@ -25,6 +25,6 @@ function error (...args) {
if (app.ipcReady) { if (app.ipcReady) {
windows.main.send('error', ...args) windows.main.send('error', ...args)
} else { } else {
app.on('ipcReady', () => windows.main.send('error', ...args)) app.once('ipcReady', () => windows.main.send('error', ...args))
} }
} }

View File

@@ -270,7 +270,7 @@ function getTorrentProgress () {
function startServer (infoHash, index) { function startServer (infoHash, index) {
var torrent = client.get(infoHash) var torrent = client.get(infoHash)
if (torrent.ready) startServerFromReadyTorrent(torrent, index) if (torrent.ready) startServerFromReadyTorrent(torrent, index)
else torrent.on('ready', () => startServerFromReadyTorrent(torrent, index)) else torrent.once('ready', () => startServerFromReadyTorrent(torrent, index))
} }
function startServerFromReadyTorrent (torrent, index, cb) { function startServerFromReadyTorrent (torrent, index, cb) {