Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for on/off line data synchronization using AngularJS and Symfony 2

I'm building a relatively complex and data heavy web application in AngularJS. I'm planning to use php as a RESTful backend (with symfony2 and FOSRESTbundle). I have spent weeks looking around for different solutions to on/off line synchronization solutions and there seem to be many half solutions (see list below for some examples). But non of them seem to fit my situation perfectly. How do I go about deciding which strategy will suite me?

What issues that might determine “best practices” for building an on/off line synchronization system in AngularJS and symfony 2 needs some research, but on the top of my head I want to consider things like speed, ease of implementation, future proof (lasting solution), extensibility, resource usage/requirements on the client side, having multiple offline users editing the same data, how much and what type of data to store.

Some of my requirements that I'm presently aware of are:

  • The users will be offline often and then needs to synchronize (locally created) data with the database
  • Multiple users share some of the editable data (potential merging issues needs to be considered).
  • User's might be logged in from multiple devices at the same time.
  • Allowing large amount of data to be stored offline(up to a gigabyte)
  • I probably want the user to be able to decide what he wants to store locally.
  • Even if the user is online I probably want the user to be able to choose whether he uses all (backend) data or only what's available locally.

Some potential example solutions

  • PouchDB - Interesting strategies for synchronizing changes from multiple sources
  • Racer - Node lib for realtime sync, build on ShareJS
  • Meteor - DDP and strategies for sync
  • ShareJS - Node.js operational transformation, inspired by Google Wave
  • Restangular - Alternative to $resource
  • EmberData - EmberJS’s ORM-like data persistence library
  • ServiceWorker
  • IndexedDB Polyfill - Polyfill IndexedDB with browsers that support WebSQL (Safari)
  • BreezeJS
  • JayData
  • Loopback’s ORM
  • ActiveRecord
  • BackBone Models
  • lawnchair - Lightweight client-side DB lib from Brian Leroux
  • TogetherJS - Mozilla Labs’ multi-client state sync/collaboration lib.
  • localForage - Mozilla’s DOMStorage improvement library.
  • Orbit.js - Content synchronization library

(https://docs.google.com/document/d/1DMacL7iwjSMPP0ytZfugpU4v0PWUK0BT6lhyaVEmlBQ/edit#heading=h.864mpiz510wz)

Any help would be much appreciated :)

like image 909
Kriss Avatar asked Apr 09 '14 09:04

Kriss


1 Answers

You seem to want a lot of stuff, the sync stuff is hard... I have a solution to some of this stuff in an OSS library I am developing. The idea is that it does versioning of local data, so you can figure out what has changed and therefore do meaningful sync, which also includes conflict resolution etc. This is sort-of the offline meteor as it is really tuned to offline use (for the London Underground where we have no mobile data signals).

I have also developed an eco system around it which includes a connection manager and server. The main project is at https://github.com/forbesmyester/SyncIt and is very well documented and tested. The test app for the ecosystem will be at https://github.com/forbesmyester/SyncItTodoMvc but I have yet to write virtually any docs for it.

It is currently using LocalStorage but will be easy to move to localForage as it actually is using a wrapper around localStorage to make it an async API... Another one for the list maybe?

like image 134
Forbesmyester Avatar answered Oct 05 '22 23:10

Forbesmyester