Created
December 19, 2014 02:27
-
-
Save devdays/30f16fc08e9938f5203a to your computer and use it in GitHub Desktop.
Single Page Application - Knockout extender for Amplify local storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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