Need to listen for XHR callbacks before constructors are run, since constructors could call native code that returns data in callback.

This commit is contained in:
Bryce Curtis 2010-09-20 15:48:37 -05:00
parent ace84227cc
commit b079a24373

View File

@ -223,18 +223,15 @@ if (typeof _nativeReady !== 'undefined') { PhoneGap.onNativeReady.fire(); }
*/ */
PhoneGap.onDeviceReady = new PhoneGap.Channel('onDeviceReady'); PhoneGap.onDeviceReady = new PhoneGap.Channel('onDeviceReady');
/**
* Start listening for XHR callbacks onDeviceReady
*/
PhoneGap.onDeviceReady.subscribeOnce(function() {
PhoneGap.JSCallback();
});
/** /**
* Create all PhoneGap objects once page has fully loaded and native side is ready. * Create all PhoneGap objects once page has fully loaded and native side is ready.
*/ */
PhoneGap.Channel.join(function() { PhoneGap.Channel.join(function() {
// Start listening for XHR callbacks
PhoneGap.JSCallback();
// Run PhoneGap constructors // Run PhoneGap constructors
PhoneGap.onPhoneGapInit.fire(); PhoneGap.onPhoneGapInit.fire();