]> khamidou — GitHub mirrors - electron.git/commitdiff
Add BIND_DONE event for process object
authorCheng Zhao <zcbenz@gmail.com>
Sat, 25 Oct 2014 15:21:17 +0000 (23:21 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 25 Oct 2014 15:21:17 +0000 (23:21 +0800)
atom/browser/lib/init.coffee
atom/common/api/atom_bindings.cc
atom/renderer/lib/init.coffee

index 59f2c5d1f2fc38a1be357599a0c950ca0441f2a0..90d52ab4f5649508fe6ea77d7353f131d6cf5bbf 100644 (file)
@@ -23,9 +23,8 @@ process.argv.splice startMark, endMark - startMark + 1
 globalPaths = module.globalPaths
 globalPaths.push path.join process.resourcesPath, 'atom', 'browser', 'api', 'lib'
 
-# Do loading in next tick since we still need some initialize work before
-# native bindings can work.
-setImmediate ->
+# Following operations need extra bindings by AtomBindings.
+process.once 'BIND_DONE', ->
   # Import common settings.
   require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init.js')
 
index 8fdc6d03ce2197bb20943a3442253d0869448ad7..32f87b83c3c2d39504dadbad054a54311ae95a3f 100644 (file)
@@ -85,6 +85,9 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
     versions->Set(mate::StringToV8(isolate, "chrome"),
                   mate::StringToV8(isolate, CHROME_VERSION_STRING));
   }
+
+  v8::Handle<v8::Value> event = mate::StringToV8(isolate, "BIND_DONE");
+  node::MakeCallback(isolate, process, "emit", 1, &event);
 }
 
 void AtomBindings::ActivateUVLoop(v8::Isolate* isolate) {
index 9f1de44a19c2a24707d93e16f3c641c268fbc95a..65bef4feb8acd23b55f2319f5d536d330122aa91 100644 (file)
@@ -84,5 +84,5 @@ if nodeIntegration in ['true', 'all', 'except-iframe', 'manual-enable-iframe']
 else
   # There still some native initialization codes needs "process", delete the
   # global reference after they are done.
-  setImmediate ->
+  process.once 'BIND_DONE', ->
     delete global.process