From e976e5098117d43e90e331746a532310b87350f8 Mon Sep 17 00:00:00 2001 From: Lorenzo Caggioni Date: Wed, 1 Jun 2016 11:40:26 -0700 Subject: [PATCH 1/3] To close issue #70 https://github.com/GoogleWebComponents/google-apis/issues/70 --- google-client-loader.html | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/google-client-loader.html b/google-client-loader.html index d68323e..5373e15 100644 --- a/google-client-loader.html +++ b/google-client-loader.html @@ -112,12 +112,25 @@ errorEventName: { type: String, value: 'google-api-load-error' + }, + + _clientLoaded: { + type: Boolean, + value: false + }, + + // Used to fix events potentially being fired multiple times by + // iron-jsonp-library. + _waiting: { + type: Boolean, + value: false } + }, - // Used to fix events potentially being fired multiple times by - // iron-jsonp-library. - _waiting: false, + observers: [ + '_tryLoadingApi(_waiting, _clientLoaded, name, version)' + ], /** * Returns the loaded API. @@ -172,6 +185,7 @@ _doneLoadingClient: function() { _clientLoaded = true; + this._clientLoaded = true; // Fix for API client load event being fired multiple times by // iron-jsonp-library. if (!this._waiting) { @@ -188,6 +202,11 @@ return handler; }, + _tryLoadingApi: function(waiting, clientLoaded, name, version) { + if (!waiting && clientLoaded && name && version) + this._loadApi(); + }, + _loadApi: function() { if (_clientLoaded && this.name && this.version) { this._waiting = false; From 52f9ecec7383c0cb811ead57336876edc013acde Mon Sep 17 00:00:00 2001 From: lcaggio Date: Fri, 10 Jun 2016 01:40:15 +0200 Subject: [PATCH 2/3] Fix comments Fix comments on commit https://github.com/lcaggio/google-apis/commit/e976e5098117d43e90e331746a532310b87350f8 --- google-client-loader.html | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/google-client-loader.html b/google-client-loader.html index 5373e15..1d2b03a 100644 --- a/google-client-loader.html +++ b/google-client-loader.html @@ -114,16 +114,18 @@ value: 'google-api-load-error' }, - _clientLoaded: { + clientLoaded: { type: Boolean, - value: false + value: false, + readOnly: true }, // Used to fix events potentially being fired multiple times by // iron-jsonp-library. - _waiting: { + waiting: { type: Boolean, - value: false + value: false, + readOnly: true } }, @@ -185,7 +187,7 @@ _doneLoadingClient: function() { _clientLoaded = true; - this._clientLoaded = true; + this._setClientLoaded(true); // Fix for API client load event being fired multiple times by // iron-jsonp-library. if (!this._waiting) { @@ -203,19 +205,20 @@ }, _tryLoadingApi: function(waiting, clientLoaded, name, version) { - if (!waiting && clientLoaded && name && version) + if (!waiting && clientLoaded && name && version) { this._loadApi(); + } }, _loadApi: function() { if (_clientLoaded && this.name && this.version) { - this._waiting = false; + this._setWaiting(false); // Is this API already loaded? if (_statuses[this.name] == 'loaded') { this._fireSuccess(); // Is a different google-api-loader already loading this API? } else if (_statuses[this.name] == 'loading') { - this._waiting = true; + this._setWaiting(true); _loaders[this.name].addEventListener(this.successEventName, this._createSelfRemovingListener(this.successEventName)); _loaders[this.name].addEventListener(this.errorEventName, From a4ce2adbe731a025ba4331275e8f08056efb9da0 Mon Sep 17 00:00:00 2001 From: lcaggio Date: Fri, 10 Jun 2016 23:56:11 +0200 Subject: [PATCH 3/3] Fix variable name --- google-client-loader.html | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/google-client-loader.html b/google-client-loader.html index 1d2b03a..d18ebe3 100644 --- a/google-client-loader.html +++ b/google-client-loader.html @@ -12,15 +12,11 @@ @@ -44,32 +39,25 @@ + \ No newline at end of file