You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by mh...@apache.org on 2010/10/30 02:59:23 UTC

svn commit: r1028959 - /shindig/trunk/features/src/main/javascript/features/container/container.js

Author: mhermanto
Date: Sat Oct 30 00:59:23 2010
New Revision: 1028959

URL: http://svn.apache.org/viewvc?rev=1028959&view=rev
Log:
Common container: add opt_callback to preloadGadget()
http://codereview.appspot.com/2750043/

Modified:
    shindig/trunk/features/src/main/javascript/features/container/container.js

Modified: shindig/trunk/features/src/main/javascript/features/container/container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/container.js?rev=1028959&r1=1028958&r2=1028959&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/container.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/container.js Sat Oct 30 00:59:23 2010
@@ -203,9 +203,10 @@ shindig.container.Container.prototype.cl
 /**
  * Pre-load one gadget metadata information. More details on preloadGadgets().
  * @param {string} gadgetUrl gadget URI to preload.
+ * @param {function(Object)=} opt_callback function to call upon data receive.
  */
-shindig.container.Container.prototype.preloadGadget = function(gadgetUrl) {
-  this.preloadGadgets([gadgetUrl]);
+shindig.container.Container.prototype.preloadGadget = function(gadgetUrl, opt_callback) {
+  this.preloadGadgets([gadgetUrl], opt_callback);
 };
 
 
@@ -214,8 +215,10 @@ shindig.container.Container.prototype.pr
  * and making an immediate call to fetch metadata of gadgets fully specified at
  * gadgetUrls. This will not render, and do additional callback operations.
  * @param {Array} gadgetUrls gadgets URIs to preload.
+ * @param {function(Object)=} opt_callback function to call upon data receive.
  */
-shindig.container.Container.prototype.preloadGadgets = function(gadgetUrls) {
+shindig.container.Container.prototype.preloadGadgets = function(gadgetUrls, opt_callback) {
+  var callback = opt_callback || function() {};
   var request = shindig.container.util.newMetadataRequest(gadgetUrls);
   var self = this;
   this.service_.getGadgetMetadata(request, function(response) {
@@ -224,11 +227,12 @@ shindig.container.Container.prototype.pr
         throw ['Failed to preload gadget ', id, '.'].join('');
       }
       self.addPreloadedGadgetUrl_(id);
-      if (response[id][shindig.container.MetadatResponse.NEEDS_TOKEN_REFRESH]) {
+      if (response[id][shindig.container.MetadataResponse.NEEDS_TOKEN_REFRESH]) {
         // Safe to re-schedule many times.
         self.scheduleRefreshTokens_();
       }
     }
+    callback(response);
   });
 };