on master help sign in
Merge branch 'dev' of https://github.com/evancz/Elm into dev
8823b01evancz
libraries/Http.elm+1
@@ -5,6 +5,7 @@
5module Http where
5module Http where
6
6
7import Native.Http (send)
7import Native.Http (send)
8+import Signal (lift)
8
9
9-- The datatype for responses. Success contains only the returned message.
10-- The datatype for responses. Success contains only the returned message.
10-- Failures contain both an error code and an error message.
11-- Failures contain both an error code and an error message.
libraries/Json.elm+5−5
@@ -78,25 +78,25 @@ find get base =
78
78
79-- Find a string value in an Elm Json object. If the key is not found or the
79-- Find a string value in an Elm Json object. If the key is not found or the
80-- value found is not a string, this returns the empty string.
80-- value found is not a string, this returns the empty string.
81−findString : String -> Dict String Value -> String
81+findString : String -> Object -> String
82findString = find string ""
82findString = find string ""
83
83
84-- Find a number value in an Elm Json object. If the key is not found or the
84-- Find a number value in an Elm Json object. If the key is not found or the
85-- value found is not a number, this returns 0
85-- value found is not a number, this returns 0
86−findNumber : String -> Dict String Value -> Float
86+findNumber : String -> Object -> Float
87findNumber = find number 0
87findNumber = find number 0
88
88
89-- Find a boolean value in an Elm Json object. If the key is not found or the
89-- Find a boolean value in an Elm Json object. If the key is not found or the
90-- value found is not a boolean, this returns the False.
90-- value found is not a boolean, this returns the False.
91−findBoolean : String -> Dict String Value -> Bool
91+findBoolean : String -> Object -> Bool
92findBoolean = find boolean False
92findBoolean = find boolean False
93
93
94-- Find an array value in an Elm Json object. If the key is not found or the
94-- Find an array value in an Elm Json object. If the key is not found or the
95-- value found is not an array, this returns an empty list.
95-- value found is not an array, this returns an empty list.
96−findArray : String -> Dict String Value -> [Value]
96+findArray : String -> Object -> [Value]
97findArray = find array []
97findArray = find array []
98
98
99-- Find an object value in an Elm Json object. If the key is not found or the
99-- Find an object value in an Elm Json object. If the key is not found or the
100-- value found is not an object, this returns an empty object.
100-- value found is not an object, this returns an empty object.
101−findObject : String -> Dict String Value -> Dict String Value
101+findObject : String -> Object -> Object
102findObject = find object Dict.empty
102findObject = find object Dict.empty
libraries/Native/Json.js+2−1
@@ -6,6 +6,7 @@ Elm.Native.Json = function(elm) {
6 var Dict = Elm.Dict(elm);
6 var Dict = Elm.Dict(elm);
7 var List = Elm.List(elm);
7 var List = Elm.List(elm);
8 var JS = Elm.JavaScript(elm);
8 var JS = Elm.JavaScript(elm);
9+ var Utils = Elm.Native.Utils(elm);
9
10
10 function fromValue(v) {
11 function fromValue(v) {
11 switch (v.ctor) {
12 switch (v.ctor) {
@@ -45,7 +46,7 @@ Elm.Native.Json = function(elm) {
45 return { ctor:"Array", _0: JS.toList(v) };
46 return { ctor:"Array", _0: JS.toList(v) };
46 }
47 }
47 var array = [];
48 var array = [];
48− for (var k in v) array.push(Tuple2(JS.toString(k), toValue(v[k])));
49+ for (var k in v) array.push(Utils.Tuple2(JS.toString(k), toValue(v[k])));
49 return { ctor:"Object", _0: Dict.fromList(JS.toList(array)) };
50 return { ctor:"Object", _0: Dict.fromList(JS.toList(array)) };
50 }
51 }
51 }
52 }
libraries/Native/Signal/Http.js+3−3
@@ -18,9 +18,9 @@ Elm.Native.Http = function(elm) {
18 function updateQueue(queue,responses) {
18 function updateQueue(queue,responses) {
19 if (queue.length > 0) {
19 if (queue.length > 0) {
20 elm.notify(responses.id, queue[0].value);
20 elm.notify(responses.id, queue[0].value);
21− if (queue[0].value.ctor !== Waiting) {
21+ if (queue[0].value.ctor !== 'Waiting') {
22− queue.shift();
22+ queue.shift();
23− setTimeout(function() { updateQueue(queue,responses); }, 0);
23+ setTimeout(function() { updateQueue(queue,responses); }, 0);
24 }
24 }
25 }
25 }
26 }
26 }