Merge branch 'dev' of https://github.com/evancz/Elm into dev

This commit is contained in:
evancz 2013-05-17 22:46:55 +02:00
commit 8823b012d1
4 changed files with 11 additions and 9 deletions

View file

@ -5,6 +5,7 @@
module Http where
import Native.Http (send)
import Signal (lift)
-- The datatype for responses. Success contains only the returned message.
-- Failures contain both an error code and an error message.

View file

@ -78,25 +78,25 @@ find get base =
-- Find a string value in an Elm Json object. If the key is not found or the
-- value found is not a string, this returns the empty string.
findString : String -> Dict String Value -> String
findString : String -> Object -> String
findString = find string ""
-- Find a number value in an Elm Json object. If the key is not found or the
-- value found is not a number, this returns 0
findNumber : String -> Dict String Value -> Float
findNumber : String -> Object -> Float
findNumber = find number 0
-- Find a boolean value in an Elm Json object. If the key is not found or the
-- value found is not a boolean, this returns the False.
findBoolean : String -> Dict String Value -> Bool
findBoolean : String -> Object -> Bool
findBoolean = find boolean False
-- Find an array value in an Elm Json object. If the key is not found or the
-- value found is not an array, this returns an empty list.
findArray : String -> Dict String Value -> [Value]
findArray : String -> Object -> [Value]
findArray = find array []
-- Find an object value in an Elm Json object. If the key is not found or the
-- value found is not an object, this returns an empty object.
findObject : String -> Dict String Value -> Dict String Value
findObject : String -> Object -> Object
findObject = find object Dict.empty

View file

@ -6,6 +6,7 @@ Elm.Native.Json = function(elm) {
var Dict = Elm.Dict(elm);
var List = Elm.List(elm);
var JS = Elm.JavaScript(elm);
var Utils = Elm.Native.Utils(elm);
function fromValue(v) {
switch (v.ctor) {
@ -45,7 +46,7 @@ Elm.Native.Json = function(elm) {
return { ctor:"Array", _0: JS.toList(v) };
}
var array = [];
for (var k in v) array.push(Tuple2(JS.toString(k), toValue(v[k])));
for (var k in v) array.push(Utils.Tuple2(JS.toString(k), toValue(v[k])));
return { ctor:"Object", _0: Dict.fromList(JS.toList(array)) };
}
}

View file

@ -18,9 +18,9 @@ Elm.Native.Http = function(elm) {
function updateQueue(queue,responses) {
if (queue.length > 0) {
elm.notify(responses.id, queue[0].value);
if (queue[0].value.ctor !== Waiting) {
queue.shift();
setTimeout(function() { updateQueue(queue,responses); }, 0);
if (queue[0].value.ctor !== 'Waiting') {
queue.shift();
setTimeout(function() { updateQueue(queue,responses); }, 0);
}
}
}