]> khamidou — GitHub mirrors - electron.git/commitdiff
Emit "exit" event for "process" when quitting.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 25 Sep 2014 13:48:30 +0000 (21:48 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 25 Sep 2014 13:48:30 +0000 (21:48 +0800)
atom/browser/lib/init.coffee
atom/renderer/lib/init.coffee

index 1802f4649d1ed5c1894bc65e159f9f7bb2007df0..ddfa56169611b6e0cc2e924027cdb8d03e3cc77b 100644 (file)
@@ -52,6 +52,10 @@ setImmediate ->
       detail: message
       buttons: ['OK']
 
+  # Emit 'exit' event on quit.
+  require('app').on 'quit', ->
+    process.emit 'exit'
+
   # Load the RPC server.
   require './rpc-server.js'
 
index 5ae2e11a644c8cfe3be7e41890ff99ef8d919b61..3fb4ceaabf42d66f974da941255b0c3d0d3a3fe1 100644 (file)
@@ -24,6 +24,10 @@ require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init.js')
 global.require = require
 global.module = module
 
+# Emit the 'exit' event when page is unloading.
+window.addEventListener 'unload', ->
+  process.emit 'exit'
+
 # Set the __filename to the path of html file if it's file: or asar: protocol.
 if window.location.protocol in ['file:', 'asar:']
   pathname =