KnockoutJS Local Storage

function AppViewModel() {
  var THING_TAG = "things";	//    The name of the local storage 
  this.thingList = ko.observableArray();

  // Load the stuff from local storage
  var stuff = localStorage.getItem(THING_TAG);
  if(stuff) { // undefined if there is nothing in local storage
    stuff = JSON.parse(actors);

    for(var i = 0; i < stuff.length; i++) {
      this.thingList.push(new Thing(stuff[i]));
  // Update local storage whenever the list changes; real applications may want to update less frequently.
  this.thingList.subscribe(function() {
    localStorage.setItem(THING_TAG, ko.toJSON(this.thingList())); // Use Knockout's JSON converter to deal with observables.
  }, this);
KnockoutJS Local Storage

This little beauty loads a list from local storage and saves it back every time it is updated. A few things to note:

  1. This sample assumes your class (in this case Thing) has a constructor which takes a basic JavaScript object with the same parameters as a parameter.
  2. You have to use KnockoutJS’ JSON parser to stringify the JSON object if your Thing equivalent has observables.