1Elm.Native.WebSocket = {};
2Elm.Native.WebSocket.make = function(elm) {
4 elm.Native = elm.Native || {};
5 if (elm.Native.WebSocket) return elm.Native.WebSocket;
7 var Signal = Elm.Signal.make(elm);
8 var JS = Elm.JavaScript.make(elm);
9 var List = Elm.Native.List.make(elm);
11 function open(url, outgoing) {
12 var incoming = Signal.constant(List.Nil);
13 var ws = new WebSocket(JS.fromString(url));
18 ws.onopen = function(e) {
19 var len = pending.length;
20 for (var i = 0; i < len; ++i) { ws.send(pending[i]); }
23 ws.onmessage = function(event) {
24 elm.notify(incoming.id, JS.toString(event.data));
28 var s = JS.fromString(msg);
29 ready ? ws.send(s) : pending.push(s);
32 function take1(x,y) { return x }
33 return A3(Signal.lift2, F2(take1), incoming, A2(Signal.lift, send, outgoing));
36 return elm.Native.WebSocket = { connect: F2(open) };
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list