File tree Expand file tree Collapse file tree 2 files changed +5
-12
lines changed Expand file tree Collapse file tree 2 files changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,10 @@ var urlParts = url.parse(typeof __resourceQuery === "string" && __resourceQuery
8
8
scriptElements [ scriptElements . length - 1 ] . getAttribute ( "src" ) . replace ( / \/ [ ^ \/ ] + $ / , "" )
9
9
) ;
10
10
11
- var recInterval = null ;
12
11
var sock = null ;
12
+ var hot = false ;
13
+ var initial = true ;
14
+ var currentHash = "" ;
13
15
14
16
var newConnection = function ( ) {
15
17
sock = new SockJS ( url . format ( {
@@ -20,14 +22,12 @@ var newConnection = function() {
20
22
pathname : urlParts . path === '/' ? "/sockjs-node" : urlParts . path
21
23
} ) ) ;
22
24
23
- clearInterval ( recInterval ) ;
24
-
25
25
sock . onclose = function ( ) {
26
26
console . error ( "[WDS] Disconnected!" ) ;
27
27
28
28
// Try to reconnect.
29
29
sock = null ;
30
- recInterval = setInterval ( function ( ) {
30
+ setTimeout ( function ( ) {
31
31
newConnection ( ) ;
32
32
} , 2000 ) ;
33
33
} ;
@@ -41,10 +41,6 @@ var newConnection = function() {
41
41
42
42
newConnection ( ) ;
43
43
44
- var hot = false ;
45
- var initial = true ;
46
- var currentHash = "" ;
47
-
48
44
function reloadApp ( ) {
49
45
if ( hot ) {
50
46
console . log ( "[WDS] App hot update..." ) ;
Original file line number Diff line number Diff line change @@ -3,22 +3,19 @@ var SockJS = require("sockjs-client");
3
3
var stripAnsi = require ( 'strip-ansi' ) ;
4
4
require ( "./style.css" ) ;
5
5
6
- var recInterval = null ;
7
6
var sock = null ;
8
7
var hot = false ;
9
8
var currentHash = "" ;
10
9
11
10
var newConnection = function ( handlers ) {
12
11
sock = new SockJS ( '/sockjs-node' ) ;
13
12
14
- clearInterval ( recInterval ) ;
15
-
16
13
sock . onclose = function ( ) {
17
14
handlers . close ( ) ;
18
15
19
16
// Try to reconnect.
20
17
sock = null ;
21
- recInterval = setInterval ( function ( ) {
18
+ setTimeout ( function ( ) {
22
19
newConnection ( handlers ) ;
23
20
} , 2000 ) ;
24
21
} ;
You can’t perform that action at this time.
0 commit comments