Fix event dispatching and attempt to reconnect on poll error
This commit is contained in:
@@ -20,7 +20,6 @@ EventPoller.prototype.start = function() {
|
||||
};
|
||||
|
||||
EventPoller.prototype.dispatchEvent = function(evt) {
|
||||
console.log(evt['type']);
|
||||
if (evt['type'] in this.handlers) {
|
||||
this.handlers[evt['type']].forEach(function (callback, idx, handlers) {
|
||||
callback(evt, evt['payload']);
|
||||
@@ -50,6 +49,7 @@ EventPoller.prototype._failedPoll = function(data) {
|
||||
});
|
||||
}
|
||||
this.id = 0;
|
||||
window.setTimeout(this.poll.bind(this), 5000);
|
||||
}
|
||||
|
||||
EventPoller.prototype._successfulPoll = function(data) {
|
||||
@@ -78,7 +78,8 @@ EventPoller.prototype._successfulPoll = function(data) {
|
||||
|
||||
var that = this;
|
||||
$(data['events']).each(function(idx, evt) {
|
||||
that.dispatchEvent(evt);
|
||||
console.log(evt['event']['type']);
|
||||
that.dispatchEvent(evt['event']);
|
||||
});
|
||||
|
||||
if (data['is-live']) {
|
||||
|
Reference in New Issue
Block a user