Need some advice from the Ionic 2 experts please, any pointers or advice would be appreciated!
We are building a mobile app that will be fetching data from a restful API. This data is then stored into a local SQLite database and the app should always be loading from the local DB and the DB then synchronised / updated via the API.
The idea is to have a service that provides the data and should be available all throughout the app and ideally immediately fetch and return the data from the DB. It should however also check for newer data on the server and update this data in the DB. This data update should also immediately then update on the interface.
What is the best approach for creating the service? And more specifically:
- At what point should should we sync the DB with the API and where would the best place be to start this sync operation? Should it be the app component constructor?
- How do we get the service to load the DB data and have the result of the sync then update the data, assuming that the interface is at this point already displaying the data from the DB?
Thanks in advance for any useful insight you might have into this.