, Http. Elm, .
TL; DR
mymsg a -> msg, a - , , mydecoder
mypost : String -> String -> (a -> msg) -> Cmd msg
a .
, , , Http.send, , .
Union, Msg - , NoOp Update - , Msg.
type Msg
= NoOp
| Update String
Update "Hello" , Msg, "Hello" Update Http.send, , ,
Update String -> Msg
Http.send:
send : (Result Error a -> msg) -> Request a -> Cmd msg
GET:
get : Int -> Difficulty -> (Result Error TriviaResult -> msg) -> Cmd msg
get amount difficulty msg =
Http.get (triviaRequestUrl amount difficulty) decoder
|> Http.send msg
:
myget1 : (WebData HttpBin -> msg) -> Cmd msg
, .