Hi All,
I’m using a Loading component to inform the user that the app is fetching records from the onboard SQLite DB.
The method fetchSchedule() determines if any schedule objects are currently stored in memory and returns them, and if not, returns them from the SQLite database.
The method works well when no objects exist in memory. The loading component is presented, remains on screen until the promise is returned from the fetchSchedule method, and the Loading component is dismissed.
On the other hand, if the objects do exist in memory, I get an unhanded promise error relating to the Loading component, and the loading component does not dismiss until the duration has elapsed:
browser_adapter.ts:73 Error: Uncaught (in promise): TypeError: Cannot read property ‘nativeElement’ of undefined
It would seem to me that the Loading component has not been initialised yet, and therefore cannot be dismissed yet. I assume this is because the fetchSchedule objects already exist in memory, and the then() runs immediately.
updateSchedule() {
this.loading = Loading.create({
content: "Loading Schedule",
duration: 10000
});
this.nav.present(this.loading);
this.scheduleController.fetchSchedule().then(data => {
this.groups = data;
this.shownSessions = data.length;
this.loading.dismiss();
});
}
Would anyone have any ideas how ensure dismiss is called and works as expected?