From: Cheng Zhao Date: Fri, 27 Dec 2013 03:08:26 +0000 (+0800) Subject: Rename 'finish-launching' event to 'ready', X-Git-Tag: v0.8.0~4^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=aedacd39d22775128fbe66495143c4b2578b61e7;p=electron.git Rename 'finish-launching' event to 'ready', 'finish-launching' is more like a OS X message name, and in atom-shell it means initialization has done, so 'ready' seems to be a better name and more easy to remember. The 'will-finish-launching' event just represents the corresponding message on OS X and is the same with 'ready' on other platforms, so we keep its name to indicate that it's only useful for OS X specified code. --- diff --git a/browser/api/atom_api_app.cc b/browser/api/atom_api_app.cc index d3b3b2e6..dc51711f 100644 --- a/browser/api/atom_api_app.cc +++ b/browser/api/atom_api_app.cc @@ -49,7 +49,7 @@ void App::OnWillFinishLaunching() { } void App::OnFinishLaunching() { - Emit("finish-launching"); + Emit("ready"); } // static diff --git a/browser/api/lib/app.coffee b/browser/api/lib/app.coffee index bcc8b7e1..241498f8 100644 --- a/browser/api/lib/app.coffee +++ b/browser/api/lib/app.coffee @@ -28,5 +28,8 @@ if process.platform is 'darwin' setBadge: bindings.dockSetBadgeText getBadge: bindings.dockGetBadgeText +# Support old event name. +app.once 'ready', -> app.emit 'finish-launching' + # Only one App object pemitted. module.exports = app diff --git a/browser/default_app/default_app.js b/browser/default_app/default_app.js index 092a1933..42b5fa60 100644 --- a/browser/default_app/default_app.js +++ b/browser/default_app/default_app.js @@ -17,7 +17,7 @@ app.on('open-url', function(event, url) { dialog.showMessageBox({message: url, buttons: ['OK']}); }); -app.on('finish-launching', function() { +app.on('ready', function() { app.commandLine.appendSwitch('js-flags', '--harmony_collections'); mainWindow = new BrowserWindow({ width: 800, height: 600 }); diff --git a/docs/api/browser/app.md b/docs/api/browser/app.md index e57df1a3..ae2ec9da 100644 --- a/docs/api/browser/app.md +++ b/docs/api/browser/app.md @@ -13,11 +13,17 @@ app.on('window-all-closed', function() { ## Event: will-finish-launching -Setup crash reporter and auto updater here. +Emitted when application has done basic startup. On Windows and Linux it is the +same with `ready` event, on OS X this event represents the +`applicationWillFinishLaunching` message of `NSApplication`, usually you would +setup listeners to `open-file` and `open-url` events here, and start the crash +reporter and auto updater. -## Event: finish-launching +Under most cases you should just do everything in `ready` event. -Do final startup like creating browser window here. +## Event: ready + +Emitted when atom-shell has done everything initializaiton. ## Event: window-all-closed diff --git a/docs/quick-start.md b/docs/quick-start.md index eb0b3cbf..82521071 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.md @@ -66,7 +66,7 @@ app.on('window-all-closed', function() { // This method will be called when atom-shell has done everything // initialization and ready for creating browser windows. -app.on('finish-launching', function() { +app.on('ready', function() { // Create the browser window, mainWindow = new Window({ width: 800, height: 600 }); // and load the index.html of the app. diff --git a/spec/static/main.js b/spec/static/main.js index 1f77bb13..674775c7 100644 --- a/spec/static/main.js +++ b/spec/static/main.js @@ -40,7 +40,7 @@ app.on('window-all-closed', function() { app.terminate(); }); -app.on('finish-launching', function() { +app.on('ready', function() { var template = [ { label: 'Atom',