Skip to content

Commit

Permalink
Fixed bugs with refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Ortega Moreno committed Sep 21, 2016
1 parent edc4dfe commit a089a60
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions traffic-incidents-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,30 +162,37 @@
refresh_time: {
value: 120000,
type: Number,
reflectToAttribute: true
reflectToAttribute: true,
observer: '_setRefreshTime'
},
},
// Life cycle functions
attached: function(){
this.$.requestGeoencode.generateRequest();
this._disableChange = true;
this._setRefresh();
},
detached: function() {
window.clearInterval(this._interval);
},
// observer

_cityChanged: function(newValue,oldValue){
if (oldValue !== undefined) {
this.refreshCity = true;
}
},
_setRefresh: function(newValue, oldValue){
if (newValue){
if (newValue && this.refresh_time && !this._interval){
this._interval = window.setInterval(this.requestTraffic.bind(this),this.refresh_time)
} else if (this._interval){
} else if (this._interval && !newValue){
window.clearInterval(this._interval);
}
},
_setRefreshTime: function(newValue){
if (this.auto_refresh && newValue && !this._interval){
this._interval = window.setInterval(this.requestTraffic.bind(this),newValue);
} else if (this.auto_refresh && newValue){
window.clearInterval(this._interval);
this._interval = window.setInterval(this.requestTraffic.bind(this),newValue);
}
},
// computed properties
Expand Down

0 comments on commit a089a60

Please # to comment.