Home Our Apps Contact Articles
Please Note: The 0.7 version of the Opensocial API rendered this object useless by depreciating instanceAppData. We've decided to keep this article online in order that you may peruse through and see some of the legacy OS code. It is, after all, historic. Saturday, December 15, 2007

An Instance App Data Getter/Setter Object.

Use this object to simplify getting/setting Instance App Data.

The instanceAppData object currently includes (2) methods:

  1. set(data, key, callBack, error): Sets Instance App Data.
    • data: (String or Array) The data to be updated.
    • key: (String) What to call the data on the server.
    • callBack: (Function) A function to fire when the data update is complete.
    • error: (Function) A function to fire in the event of an error.
  2. get(key(s), callBack, error): Gets Instance App Data
    • key(s): (String or Array) the data key(s) to fetch.
    • callBack: (Function) The function to receive the data to when it's ready.
    • error: (Function) The function to fire in case of an error.

The instanceAppData.set method will return NO DATA. If an error occurs, it will call the custom error function.

The instanceAppData.get method will return one object (which is sent to the callback function). If an error occurred, the error function will be fired. The returned object contains all of the requested data in the following format:


    returnedObj:{
                    dataKey1:uniqueValue1 // Array OR String
                    ,dataKey2:uniqueValue2 // Array OR String
                    ,...
              }        
        

Note that the returned data will be an Array or a String depending on what type was sent into the instanceAppData.set method. Here is an example of using this object to get and print some data:


             // getting back data
            instanceAppData.get( // single method call... (3) arguments
                ['myData', 'myData2']
                ,handleData
                ,function(e){ alert(e); }
            );                                   

        function handleData(ret){ // the data handler function
             // look for myData (Assumed to be a String)
             alert( 'myData: '+ret['myData'] );
             // look for myData2 (Assumed to be an Array)
             var myData2 = ret['myData2'];
             for( var i = 0; i < myData2.length; i++ ){
                alert( myData2[i] );   
             }            
        }         
        

This object is the result of our Instance App Data Tutorial, which explains in detail the steps taken to create this object. This file should be considered public domain.


To view the object code, please use this link: http://www.iwiddit.com/article_xml/instanceAppData.html A working xml example can be found here: http://www.iwiddit.com/article_xml/instanceAppData.xml

[ Page Top ](c)2009 iWiddit.com - Privacy Policy - Feedback - SiteMap

iWiddit Logo iWiddit Opensocial Developers