Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 19, 2014 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/30f16fc08e9938f5203a to your computer and use it in GitHub Desktop.
Save devdays/30f16fc08e9938f5203a to your computer and use it in GitHub Desktop.
Single Page Application - Knockout extender for Amplify local storage
ko.extenders.localStore = function (target, key) {
var value = amplify.store(key) || target();
var result = ko.computed({
read: target,
write: function(newValue) {
amplify.store(key, newValue);
target(newValue);
}
});
result(value);
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment