From 7481028bc032f84e481d66ee32e9816e4c61f9b2 Mon Sep 17 00:00:00 2001 From: Matt Oliver Date: Sat, 28 Mar 2020 16:11:19 -0400 Subject: [PATCH 1/2] Replace this with eventSource --- EventSource.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/EventSource.js b/EventSource.js index e160834..5c5d668 100644 --- a/EventSource.js +++ b/EventSource.js @@ -53,14 +53,14 @@ var EventSource = function(url, options) { lastIndexProcessed = 0; xhr.timeout = - this.OPTIONS && this.OPTIONS.timeout !== undefined - ? this.OPTIONS.timeout + eventsource.OPTIONS && eventsource.OPTIONS.timeout !== undefined + ? eventsource.OPTIONS.timeout : 50000; xhr.onreadystatechange = function() { if ( - this.readyState == 3 || - (this.readyState == 4 && this.status == 200) + eventsource.readyState == 3 || + (eventsource.readyState == 4 && eventsource.status == 200) ) { // on success if (eventsource.readyState == eventsource.CONNECTING) { @@ -112,14 +112,14 @@ var EventSource = function(url, options) { } } - if (this.readyState == 4) pollAgain(interval); + if (eventsource.readyState == 4) pollAgain(interval); // don't need to poll again, because we're long-loading } else if (eventsource.readyState !== eventsource.CLOSED) { - if (this.readyState == 4) { + if (eventsource.readyState == 4) { // and some other status pollAgain(interval); - } else if (this.readyState == 0) { + } else if (eventsource.readyState == 0) { // likely aborted pollAgain(interval); } From 604bfb458411f64790fba3b03f596d04f60a2c3e Mon Sep 17 00:00:00 2001 From: Matt Oliver Date: Sat, 28 Mar 2020 16:26:07 -0400 Subject: [PATCH 2/2] Revert a couple fixes --- EventSource.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/EventSource.js b/EventSource.js index 5c5d668..3f8dc01 100644 --- a/EventSource.js +++ b/EventSource.js @@ -59,8 +59,8 @@ var EventSource = function(url, options) { xhr.onreadystatechange = function() { if ( - eventsource.readyState == 3 || - (eventsource.readyState == 4 && eventsource.status == 200) + this.readyState == 3 || + (this.readyState == 4 && this.status == 200) ) { // on success if (eventsource.readyState == eventsource.CONNECTING) { @@ -112,14 +112,14 @@ var EventSource = function(url, options) { } } - if (eventsource.readyState == 4) pollAgain(interval); + if (this.readyState == 4) pollAgain(interval); // don't need to poll again, because we're long-loading } else if (eventsource.readyState !== eventsource.CLOSED) { - if (eventsource.readyState == 4) { + if (this.readyState == 4) { // and some other status pollAgain(interval); - } else if (eventsource.readyState == 0) { + } else if (this.readyState == 0) { // likely aborted pollAgain(interval); }