Introducing Backbone.Store ... JSON storage for Backbone.

Right now, you can't do much better for quickly developing javascript applications and modules than the triumvirate of  Backbone, jQuery, and Require.  Each of these libraries fit together so well (IMO), and have increased my personal productivity immensely - improving quality, performance, readability, and consistency. There was already a great library for Backbone to utilize HTML5 localStorage functionality; however, there were a few drawbacks to the library that caused me to look in another direction, and ultimately led me to creating Backbone.store.

My two greatest needs were:

  1. The ability to utilize the storage mechanism as a cache.
  2. A greater range of compatibility outside of localStorage support.

To meet these needs, I turned to Lawnchair, a JSON storage library with a wide range of adapters for different storage types, mixed in a little bit of the aforementioned backbone.localstorage plugin, and came out with the beginnings of a (hopefully) useful storage middleware.

While the overall project is in very early stages, its not too soon to look at, play with, and provide feedback on.

Download / clone from Github.

Features:

  1. Can be used with or without a backend server
  2. Configurable cache time to live
  3. Configure when to use server vs cached model - great for list  vs. detail of a record
  4. Does not require localStorage support, though a Lawnchair adapter may be needed to get the support you want.

Planned enhancements:

  1. Batch model upload to server (online/offline or time delayed)
  2. Parameter based caching (for caching paging / search results / etc)
  3. Remove Require (AMD) dependency
  4. ??? (accepting ideas)

Also included in the project is a basic 'Todo' style application including a CodeIgniter (php) based RESTful web server and structure, and a Backbone/Require/jQuery front-end consisting of a list/detail view with complete CRUD control and proper routing using both direct (bookmarkable) URL access and pushState routing.

Again, this project is nowhere near complete, so I'm sure there are some bugs... Still on the todo list is to add test cases using Sinon and Jasmine, and there is a known issue with the list -> detail -> list navigation.