Cordova deviceready event listener in ionic2: is it necessary to use correctly cordova-sqlite-storage?


#1

On the page regarding the Cordova-sqlite-storage, It is written :

IMPORTANT: Like with the other Cordova plugins your application must wait for the deviceready event. This is especially tricky in Angular/ngCordova/Ionic controller/factory/service callbacks which may be triggered before the deviceready event is fired.

I don’t find anywhere information stating that is not anymore the case with Ionic2. So I guess it means: document.addEventListener('deviceready', function() { db = window.sqlitePlugin.openDatabase({name: 'demo.db', location: 'default'}); });
Is still necessary?


#2

Yes that’s necessary for pretty much all Cordova plugins. But with Ionic you can use Platform.ready() that returns a promise instead of document.addEventListener.