Retrieving all data at log in

Hi Guys,

I’m pretty new to Ionic and I’m creating a mobile app and was thinking to execute all database retrieval asynchronously after the user logs in and perhaps listen or like have a subscriber to receive that data and save it in local storage. This way it will make transitions to pages a lot faster since it won’t have to query on demand. Thing is, I don’t know where to start. Has somebody created something like this? Can you post a sample code? Is this a good practice? If not, how do I better handle it?

Also can you guys recommend an article/blog/book that I should read to improve mobile app development in Ionic? Thanks in advance folks.

Smells like premature optimization to me. I would forget about this until you have the app working and some concrete data suggesting that there’s a perceived performance issue here. In the meantime, though, it’s always a good idea to wall off all your data handling into services, as opposed to distributing it throughout page controllers. That way, if you do decide at a later point to change the strategy by which you fetch data, you only have to modify a single class to do so, and none of your component code need change at all.

Thank you for your reply. I already have the app working and I’m just looking for optimizations since I have only tested it locally and haven’t been able to use it in production where internet connection is not always reliable. Although, I might have messed up with data fetching since everything is scattered all over my pages. I’m not using any service at the moment. Walling off all data handling into services is definitely better. Can you provide me with a sample for that? Like how would you do it in the service and have the pages would have an access to read/write the data via the service?

Tour of Heroes part 4.

Thanks, I’ll have a read on that.