From 24b4fcea15a06b1b4ab00626e5ac5e1d8e1dc1c3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 25 Oct 2014 23:21:17 +0800 Subject: [PATCH] Add BIND_DONE event for process object --- atom/browser/lib/init.coffee | 5 ++--- atom/common/api/atom_bindings.cc | 3 +++ atom/renderer/lib/init.coffee | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 59f2c5d1f2fc..90d52ab4f564 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -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') diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index 8fdc6d03ce21..32f87b83c3c2 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -85,6 +85,9 @@ void AtomBindings::BindTo(v8::Isolate* isolate, versions->Set(mate::StringToV8(isolate, "chrome"), mate::StringToV8(isolate, CHROME_VERSION_STRING)); } + + v8::Handle event = mate::StringToV8(isolate, "BIND_DONE"); + node::MakeCallback(isolate, process, "emit", 1, &event); } void AtomBindings::ActivateUVLoop(v8::Isolate* isolate) { diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index 9f1de44a19c2..65bef4feb8ac 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -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