simple-storagenot synchronized. But you can synchronize it with minimal effort.
Trick it into saving the object storage, it is serialized by definition as a string preference and tells the synchronization service to synchronize it.
Lets you name this preference syncstorageand mark it as synchronized.
var self = require("sdk/self");
var prefs = require("sdk/preferences/service");
prefs.set("services.sync.prefs.sync.extensions." + self.id + ".syncstorage", true);
When saving anything in, simple-storagereflect the change to syncstorage.
var sp = require("sdk/simple-prefs");
var ss = require("sdk/simple-storage");
sp.prefs["syncstorage"] = JSON.stringify(ss.storage);
For the opposite effect, see syncstoragefor changes.
sp.on("syncstorage", function(prefname){
ss.storage = JSON.parse(sp.prefs["syncstorage"]);
})
And last, but not least, it would be good and, possibly, required for synchronization only with the explicit consent of the user.
source
share