From 8292fda6a01747f23b71a5893a34e9e3bd16564a Mon Sep 17 00:00:00 2001 From: Clark Du Date: Sun, 6 Oct 2019 20:55:37 +0100 Subject: [PATCH] feat: add disconnect on event source wrapper --- client.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client.js b/client.js index abc95ed..929b8ed 100644 --- a/client.js +++ b/client.js @@ -103,9 +103,13 @@ function EventSourceWrapper() { } } - function handleDisconnect() { + function disconnect() { clearInterval(timer); source.close(); + } + + function handleDisconnect() { + disconnect(); setTimeout(init, options.timeout); } @@ -113,6 +117,7 @@ function EventSourceWrapper() { addMessageListener: function(fn) { listeners.push(fn); }, + disconnect: disconnect, }; }