Angular 2 Data Saving

Our development team began a great transition to the Angular2 / Ionic2 infrastructure, and one small detail left us puzzled - what is the best way to achieve data continuity? I found an almost two-year-old Google Doc in design to save Ang2 data, however it doesn't seem to be implemented at all. I need the most important functions:

  • client-server data binding, so every change is automatically committed
  • local dataset for working with the application offline
  • offline operation caching, synchronization with the server immediately upon reconnection

(In short, the functionality of Swarm.js, for example) I searched for blogs, stackoverflow, but haven’t answered anything yet - as far as I understand, I can’t even use widespread external solutions like PouchDB to solve this problem, and constantly do HTTP receiving / post calls with manual caching in localStorage will not do this for the projects we are working on. What do you think? Is there any way to achieve this?

+5
source share
1 answer

PouchDB dev is here. Basically, you can use any client database with Angular. Personally, I wrote several Angular applications that used direct PouchDB (I never saw the need for angular-pouchdb TBH). Here is an open source example: https://github.com/pouchdb/npm-browser

PouchDB is optimized for synchronization with CouchDB. If you just want the simple Key Storage API to be replaced by LocalStorage, I would recommend LocalForage . It is based on a promise, so you can just wrap it with $q.when() and use it in an Angular service, and it should feel pretty native to Angular.

+4
source

Source: https://habr.com/ru/post/1244661/


All Articles