cordova-discuss
cordova-discuss copied to clipboard
Improve startup in JavaScript
The requirement to wait for the deviceready
event has caused some major confusion and other trouble for people using Ionic 2 and other Angular derivatives with the sqlite plugin. Here are a couple examples:
- https://github.com/litehelpers/Cordova-sqlite-storage/issues/598
- https://github.com/litehelpers/Cordova-sqlite-storage/issues/594
I think https://github.com/litehelpers/Cordova-sqlite-storage/issues/594#issuecomment-271609073 by @rodineijf really helps to highlight this problem:
Hi @brodybits, by default the attribution of rootPage on ionic 2 is on declaration of var rootPage. I can solve my problem moving the rootPage attribution to the platformReady on app.component
initializeApp() { this.platform.ready().then(() => { this.rootPage = MyPage; StatusBar.styleDefault(); Splashscreen.hide(); }); }
In contrast I heard that in the React Native there is no requirement to wait for the deviceready
event.
I think the solution is to fix cordova.js to prepare the all of the JavaScript from the plugins upon loading and to have cordova.exec put the native calls into a queue until the initialization is confirmed to be completed.
I will take a look at fixing this when I get a chance.