Skip to content

Commit 1a1df45

Browse files
committed
add js file to js-sources
1 parent bb4eed9 commit 1a1df45

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

solga-client-ghcjs/jsbits/xhr.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// taken from
2+
// <https://github.com/ghcjs/ghcjs-base/blob/eacf95aac3061275699563e1802eabe4a8f4aaec/jsbits/xhr.js>
3+
// see that page for license
4+
5+
function h$solgaSendXHR(xhr, d, cont) {
6+
xhr.addEventListener('error', function () {
7+
cont(2);
8+
});
9+
xhr.addEventListener('abort', function() {
10+
cont(1);
11+
});
12+
xhr.addEventListener('load', function() {
13+
cont(0);
14+
});
15+
if (d) {
16+
xhr.send(d);
17+
} else {
18+
xhr.send();
19+
}
20+
}
21+

solga-client-ghcjs/solga-client-ghcjs.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ library
2525
hs-source-dirs: src
2626
default-language: Haskell2010
2727
ghc-options: -Wall
28+
js-sources: jsbits/xhr.js

solga-client-ghcjs/src/Solga/Client/GHCJS.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ data XHRError =
170170
newtype GetResponse a b = GetResponse {unGetResponse :: Either XHRError (Response a) -> IO b}
171171

172172
foreign import javascript interruptible
173-
"h$anapoSendXHR($1, null, $c);"
173+
"h$solgaSendXHR($1, null, $c);"
174174
js_send0 :: DOM.XMLHttpRequest -> IO Int
175175
foreign import javascript interruptible
176-
"h$anapoSendXHR($1, $2, $c);"
176+
"h$solgaSendXHR($1, $2, $c);"
177177
js_send1 :: DOM.XMLHttpRequest -> DOM.JSVal ->IO Int
178178

179179
performXHR :: DOM.XMLHttpRequestResponseType -> Request -> IO (Either XHRError (Response DOM.JSVal))

0 commit comments

Comments
 (0)