Using Backbone.js offline
Asked Answered
C

4

19

I'm evaluating Backbone.js for keeping data and UI synchronized in my web app. However, much of Backbone's value seems to lie in its use of RESTful interfaces. Though I may add server-side backup in the future, my primary use case involves storing all data offline using HTML5 local storage.

Is Backbone overkill for such a use case? If so, is there a better solution, focused solely on updating UI when data changes, and vice versa? (I'm also looking into Knockout and Javascript MVC.)

EDIT: I'm also now looking into Angular.js and jQuery Data Link.

Crosstie answered 28/1, 2011 at 22:12 Comment(0)
C
28

Backbone.js works just as well with local storage as it does with RESTful queries.

I'm a learn-by-example kind of guy so here are some links to get you started:

Claudie answered 29/1, 2011 at 13:53 Comment(0)
S
9

In the past weeks I have evaluated different solution for a scenario close to yours; being a project done in my personal free time and not being a good Javascript programmer, all I needed was something easy to learn to avoid starting from scratch.

Not surprisingly, I had the same candidate: Backbone.js, Javascript MVC and Knockout.js.

Backbone.js won:

  • I wasn't be required to follow conventions or replace what was already in place
  • I've easly hacked in its codebase to understand what wasn't clear from the documentation
  • I've successfully ignored a large amount of its features that was not interesting for me
  • It gave acceptable performance on busy pages
  • It works

Backbone.js is lightweight and relatively magic-free; you will probably use a small subset of its feature but it provieds a solid base to develop your solution.

Selectman answered 29/1, 2011 at 21:0 Comment(0)
T
4

I know it's been a while but you may want to check out backbone-offline project on github: https://github.com/Ask11/backbone.offline

Tamasha answered 19/7, 2012 at 3:48 Comment(0)
S
1

You can also take a look at AFrameJS. I have created a bare-bones proof of concept note-taking app that works offline using HTML5 WebSQL spec, but also want to create an adapter that uses localStorage as well. My personal opinion (and I am biased) is that using an MVC library of any sorts is going to help you in the long run - the value of libraries such as Backbone, Knockout, and AFrame lie in their ability to reduce the cognitive load of the developer by enforcing a good separation of concerns. Data related functionality reside in models, displaying that data resides in Views, and the glue is kept in Controllers. Separating these three concepts might seem pedantic at first, but the end result is code that is easier to develop, easier to test, easier to maintain, and easier to reuse. A basic tutorial on using AFrameJS can be found on my site at: http://www.shanetomlinson.com/2011/aframejs-tutorial-for-noobs/

Stubblefield answered 2/2, 2011 at 0:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.