Currently, I am utilizing BaQend and Ionic2 to implement certain tasks at the start of my application.
1. Database Readiness
Instead of repeating this process on every page:
ionViewCanEnter(): Promise<baqend> {
// Verify Baqend SDK readiness and wait for initialization
return this.ready.resolve().then(db => this.db = db);
}
I attempted an alternative approach, however it did not yield the desired results:
initializeApp() {
this.platform.ready().then(() => {
// Platform and plugins are ready.
// Perform any necessary native operations here.
this.statusBar.styleDefault();
this.splashScreen.hide();
return this.ready.resolve().then(db => this.db = db);
});
}
2. User Login Status Check
During app initialization, it is essential to assess the user's login status. If the user is not logged in, prompt them to sign in using the LoginModal.
ionViewWillEnter(){
if (this.db.User.me) {
console.log(this.db.User.me.username,' entered HomePage with ID ', this.db.User.me.id);
} else {
this.openLoginModal()
console.log('Hello Anonymous');
}
}
The above code functions effectively for the rootPage, although integrating it into the application startup would be more beneficial.
Any suggestions or recommendations?