scttnlsn / backbone.io

Backbone.js sync via Socket.IO

Home Page:http://scttnlsn.github.io/backbone.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Seeking expertise on a use case for this project that involves localStorage.

howardroark opened this issue · comments

We are building an open-source time tracking tool. It is meant to be a super simple interface that caters to people with a lot going on during the day. It will be built to run as a web interface and a PhoneGap app.

https://github.com/openops/mom

The idea is to allow the tool to be used on it's own or optionally tied to a 2-way relationship with a remote service (likely running MongoDB or CouchDB). The idea is to ensure that the state of the application is mirrored in a single JSON object which is stored in localStorage. This will allow the app to be actively reloaded in the browser and maintain state. When developing we aim to ensure that we utilize collection/model events and sync as expected.

We are also looking to ensure that when paired with a remote service that the app would seamlessly respond to remote changes in data and vice-versa. These changes in data would need to be mirrored in localStorage as well. This way the app can can be ensured to set itself up as it makes its connections or if connections fail. Ideally all of this data work would be accomplished whenever sync is run.

Have you heard of use-case like this before? Do you see backbone.io tool fitting in, or maybe being slightly extended?

Thanks so much for any thoughts!

The main use case for backbone.io is for keeping model/collection data synced between all connected clients in (soft) realtime. Part of this could absolutely include saving the data received by a client into local storage.

If you intend to allow your application to work in an offline setting and then sync when it comes online you're going to need to devise some sort of additional synchronization strategy in your model layer (i.e. pull unseen changes from server, resolve conflicts, push unsaved changes back to server) and this is largely orthogonal to the transport mechanism (you could just as well do this via XHR/HTTP).

Please re-open this issue if you have any more questions.

Thank you so much for this well considered response! Essentially I want to work away on a pattern where the UI is a representation of a JSON state. The idea being that you sync the state between many devices, some of which may represent the data in different ways. For instance one device may be a list of slides to display, and the other device may show full slides themselves. They would stay in sync with some procedures that run through a central service running Mongo or something. This would also allow the centralized services to intervene with the state when needed and seamlessly update the user's experience as well. I think it would really show its use when it comes to operational tools like todo apps, calendars, time trackers... Consider it the evolution of the RESTful procedure. I got a lot of inspiration from the config management project SaltStack and how it is designed.