Search code examples
synchronizationnativescriptnativescript-angularofflineappsoffline-mode

Nativescript angular offline app tutorial


do you know where can I get full tutorial on building an android app using nativescript angular which is offline-first and could sync with remote server (rest api) using mysql database?

This is my first time to learn how to build an android app using nativescript angular and I need to learn how to build an offline-first app which could sync everything that change on local to remote server(mysql). I do have a rest api built with laravel. Could you guide me please?


Solution

  • I can just highlight some of the key points to you, don't have any tutorial ...

    You need to store data locally :

    You need to architecture your app logically in layers :

    • components display screens and fetch data directly from your local database (what I call a repository)
    • repository get data from database and send it to the layer which need it (components)
    • repository also fetch new data from network and fill up your local database
    • your components needs to be aware that your local database got updated => use https://github.com/ReactiveX/rxjs
    • network services (list of all the apis you'll call)
    • network models (and conversion from/to databaseModel)
    • database DAO
    • database models
    • etc

    You need to detect online/offline :

    If you have massive i/o, :

    Then you'll need to code your own synchronisation logic ;)

    Good luck