Skip to content

Commit 67ff2d5

Browse files
committed
Add socket handlers.
1 parent 1bc9212 commit 67ff2d5

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

client/index.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,47 @@ var hot = false;
1313
var initial = true;
1414
var currentHash = "";
1515

16+
var onSocketMsg = {
17+
hot: function() {
18+
hot = true;
19+
console.log("[WDS] Hot Module Replacement enabled.");
20+
},
21+
invalid: function() {
22+
console.log("[WDS] App updated. Recompiling...");
23+
},
24+
hash: function(hash) {
25+
currentHash = hash;
26+
},
27+
"still-ok": function() {
28+
console.log("[WDS] Nothing changed.")
29+
},
30+
ok: function() {
31+
if(initial) return initial = false;
32+
reloadApp();
33+
},
34+
warnings: function(warnings) {
35+
console.log("[WDS] Warnings while compiling.");
36+
for(var i = 0; i < warnings.length; i++)
37+
console.warn(stripAnsi(warnings[i]));
38+
if(initial) return initial = false;
39+
reloadApp();
40+
},
41+
errors: function(errors) {
42+
console.log("[WDS] Errors while compiling.");
43+
for(var i = 0; i < errors.length; i++)
44+
console.error(stripAnsi(errors[i]));
45+
if(initial) return initial = false;
46+
reloadApp();
47+
},
48+
"proxy-error": function(errors) {
49+
console.log("[WDS] Proxy error.");
50+
for(var i = 0; i < errors.length; i++)
51+
console.error(stripAnsi(errors[i]));
52+
if(initial) return initial = false;
53+
reloadApp();
54+
}
55+
};
56+
1657
var newConnection = function() {
1758
sock = new SockJS(url.format({
1859
protocol: urlParts.protocol,

0 commit comments

Comments
 (0)