You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/03/20 16:48:48 UTC
[04/40] js commit: Add onPluginsReady event,
and join on it before firing onDeviceReady
Add onPluginsReady event, and join on it before firing onDeviceReady
This happens only when a magic variable (window.__onPluginsLoadedHack)
is set, which is done by the generated code in the automatic plugin
loader prototype. A temporary hack that can be removed when the
prototype is either rolled into the main line or scrapped.
The behavior is unchanged when the variable is not set.
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/6abe4c9b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/6abe4c9b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/6abe4c9b
Branch: refs/heads/cb2227
Commit: 6abe4c9b5863dad21152a178874d476fcce473c2
Parents: 48220f8
Author: Braden Shepherdson <br...@gmail.com>
Authored: Thu Feb 21 16:11:31 2013 -0500
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Thu Feb 21 16:11:31 2013 -0500
----------------------------------------------------------------------
lib/common/channel.js | 4 ++++
lib/scripts/bootstrap.js | 11 ++++++++++-
2 files changed, 14 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6abe4c9b/lib/common/channel.js
----------------------------------------------------------------------
diff --git a/lib/common/channel.js b/lib/common/channel.js
index 6e90603..38daedf 100644
--- a/lib/common/channel.js
+++ b/lib/common/channel.js
@@ -242,6 +242,10 @@ channel.createSticky('onCordovaInfoReady');
// Event to indicate that the connection property has been set.
channel.createSticky('onCordovaConnectionReady');
+// Event to indicate that all automatically loaded JS plugins are loaded and ready.
+// This is used in conjunction with the automatic plugin JS loading CLI prototype.
+channel.createSticky('onPluginsReady');
+
// Event to indicate that Cordova is ready
channel.createSticky('onDeviceReady');
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6abe4c9b/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 396862e..437604d 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -40,6 +40,15 @@
/**
* Create all cordova objects once page has fully loaded and native side is ready.
*/
+ var joinEvents = [ channel.onDOMContentLoaded, channel.onNativeReady ];
+
+ // If this property is set to something truthy, join on onPluginsReady too.
+ // This property is set by the automatic JS installation prototype in cordova-cli,
+ // and will be removed when the prototype either becomes mainline or is dropped.
+ if (window.__onPluginsLoadedHack) {
+ joinEvents.push(channel.onPluginsReady);
+ }
+
channel.join(function() {
var builder = require('cordova/builder'),
platform = require('cordova/platform');
@@ -60,6 +69,6 @@
require('cordova').fireDocumentEvent('deviceready');
}, channel.deviceReadyChannelsArray);
- }, [ channel.onDOMContentLoaded, channel.onNativeReady ]);
+ }, joinEvents);
}(window));