@@ -148,11 +148,13 @@ jsaddleJs = "\
149 \ ws.onopen = function(e) {\n\
149 \ ws.onopen = function(e) {\n\
150 \ " <> initState <> "\n\
150 \ " <> initState <> "\n\
151− \ var inXhrSend = false;\n\
153 \ ws.onmessage = function(e) {\n\
152 \ ws.onmessage = function(e) {\n\
154− \ if(inXhrSend) return;\n\
155 \ var batch = JSON.parse(e.data);\n\
153 \ var batch = JSON.parse(e.data);\n\
154+ \ if(inCallback > 0) {\n\
155+ \ asyncBatch = batch;\n\
156 \ if(typeof batch === \"string\") {\n\
158 \ if(typeof batch === \"string\") {\n\
157 \ syncKey = batch;\n\
159 \ syncKey = batch;\n\
158 \ var xhr = new XMLHttpRequest();\n\
160 \ var xhr = new XMLHttpRequest();\n\
@@ -167,12 +169,10 @@ jsaddleJs = "\
168 \ " <> runBatch (\a -> "ws.send(JSON.stringify(" <> a <> "));")
170 \ " <> runBatch (\a -> "ws.send(JSON.stringify(" <> a <> "));")
169 (Just (\a -> "(function(){\n\
171 (Just (\a -> "(function(){\n\
170− \ inXhrSend = true;\n\
171 \ var xhr = new XMLHttpRequest();\n\
172 \ var xhr = new XMLHttpRequest();\n\
172 \ xhr.open('POST', '/sync/'+syncKey, false);\n\
173 \ xhr.open('POST', '/sync/'+syncKey, false);\n\
173 \ xhr.setRequestHeader(\"Content-type\", \"application/json\");\n\
174 \ xhr.setRequestHeader(\"Content-type\", \"application/json\");\n\
174 \ xhr.send(JSON.stringify(" <> a <> "));\n\
175 \ xhr.send(JSON.stringify(" <> a <> "));\n\
175− \ inXhrSend = false;\n\
176 \ return JSON.parse(xhr.response);})()")) <> "\
176 \ return JSON.parse(xhr.response);})()")) <> "\