You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Gregg Horan <gr...@dealer.com> on 2010/08/04 16:31:13 UTC

UserPref persistence via appData

Thought I might be able to kill 2 birds with one stone when I  
implement the appData backend if I could implement the  
shindig.Container.prototype.userPrefStore as an appData passthrough.   
Append a prefix to the appId so the persistent data can be  
differentiated (between real appData and userpref data for the same  
appId).

If you'll forgive the (lack of) accuracy of the js...  has anyone  
tried anything like this?

shindig.AppDataBasedUserPrefStore.prototype.getPrefs = function 
(gadget) {
     return osapi.appdata.get({
           appId: "UP_" + gadget.id,
           userId: "@me",
           fields: "@all" });
};

shindig.AppDataBasedUserPrefStore.prototype.savePrefs = function 
(gadget) {
     osapi.appdata.update({
           appId: "UP_" + gadget.id,
           userId: "@me",
           data: gadget.UserPrefs });
};

shindig.AppDataBasedUserPrefStore = function() {
   gadgets.UserPrefStore.call(this);
};

shindig.AppDataBasedUserPrefStore.inherits(shindig.UserPrefStore);

shindig.Container.prototype.userPrefStore = new  
shindig.AppDataBasedUserPrefStore();