ng-event-source
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -16,3 +16,3 @@ /** @license | ||
function Map() { | ||
function Map () { | ||
this.data = {}; | ||
@@ -31,7 +31,7 @@ } | ||
function EventTarget() { | ||
function EventTarget () { | ||
this.listeners = new Map(); | ||
} | ||
function throwError(e) { | ||
function throwError (e) { | ||
setTimeout(function () { | ||
@@ -100,3 +100,3 @@ throw e; | ||
function Event(type) { | ||
function Event (type) { | ||
this.type = type; | ||
@@ -106,3 +106,3 @@ this.target = undefined; | ||
function MessageEvent(type, options) { | ||
function MessageEvent (type, options) { | ||
Event.call(this, type); | ||
@@ -134,3 +134,3 @@ this.data = options.data; | ||
function getDuration(value, def) { | ||
function getDuration (value, def) { | ||
var n = value; | ||
@@ -143,3 +143,3 @@ if (n !== n) { | ||
function fire(that, f, event) { | ||
function fire (that, f, event) { | ||
try { | ||
@@ -154,3 +154,3 @@ if (typeof f === "function") { | ||
function EventSourcePolyfill(url, options) { | ||
function EventSourcePolyfill (url, options) { | ||
url = url.toString(); | ||
@@ -165,2 +165,6 @@ | ||
} | ||
var connectionTimeout = 0; | ||
if (options && options.connectionTimeout) { | ||
connectionTimeout = options.connectionTimeout; | ||
} | ||
var lastEventId = ""; | ||
@@ -190,3 +194,3 @@ var headers = (options && options.headers) || {}; | ||
function close() { | ||
function close () { | ||
currentState = CLOSED; | ||
@@ -208,3 +212,3 @@ if (xhr != undefined) { | ||
function onEvent(type) { | ||
function onEvent (type) { | ||
var responseText = ""; | ||
@@ -218,2 +222,3 @@ if (currentState === OPEN || currentState === CONNECTING) { | ||
} | ||
var event = undefined; | ||
@@ -407,15 +412,15 @@ var isWrongStatusCodeOrContentType = false; | ||
function onProgress() { | ||
function onProgress () { | ||
onEvent("progress"); | ||
} | ||
function onLoad() { | ||
function onLoad () { | ||
onEvent("load"); | ||
} | ||
function onError() { | ||
function onError () { | ||
onEvent("error"); | ||
} | ||
function onReadyStateChange() { | ||
function onReadyStateChange () { | ||
if (xhr.readyState === 4) { | ||
@@ -434,3 +439,3 @@ if (xhr.status === 0) { | ||
// workaround for Opera issue with "progress" events | ||
timeout0 = setTimeout(function f() { | ||
timeout0 = setTimeout(function f () { | ||
if (xhr.readyState === 3) { | ||
@@ -501,2 +506,11 @@ onEvent("progress"); | ||
if (connectionTimeout > 0) { | ||
xhr.timeout = connectionTimeout; | ||
xhr.ontimeout = function (e) { | ||
if (errorOnTimeout) { | ||
throw new Error("No ack received"); | ||
} | ||
} | ||
} | ||
if ("withCredentials" in xhr) { | ||
@@ -543,3 +557,3 @@ // withCredentials should be set after "open" for Safari and Chrome (< 19 ?) | ||
function F() { | ||
function F () { | ||
this.CONNECTING = CONNECTING; | ||
@@ -549,2 +563,3 @@ this.OPEN = OPEN; | ||
} | ||
F.prototype = EventTarget.prototype; | ||
@@ -562,2 +577,2 @@ | ||
export { EventSourcePolyfill }; | ||
export {EventSourcePolyfill}; |
{ | ||
"name": "ng-event-source", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"main": "eventsource.js", | ||
@@ -5,0 +5,0 @@ "typings": "typings.d.ts", |
@@ -24,2 +24,3 @@ declare enum ReadyState {CONNECTING = 0, OPEN = 1, CLOSED = 2} | ||
checkActivity?: boolean; | ||
connectionTimeout?: number; | ||
} | ||
@@ -26,0 +27,0 @@ |
Sorry, the diff of this file is not supported yet
175873
3928
22