Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lcaggio committed Jun 1, 2016
1 parent 1e2d574 commit e976e50
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions google-client-loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit e976e50

Please sign in to comment.