aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-09-13 22:12:15 +0200
committerNoah Loomans <noahloomans@gmail.com>2017-09-13 22:12:15 +0200
commite8585ef26abefbc98437781f59ac2198e1d515ce (patch)
treedd1ce3b9081d74f6c2cf88c3a2028f8d6f11ae47 /src/client/elm
parent5348b220c8ec071eee01578f0ea525e28d3a5c3f (diff)
Refactor DecodeFlags
Diffstat (limited to 'src/client/elm')
-rw-r--r--src/client/elm/DecodeFlags.elm19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/client/elm/DecodeFlags.elm b/src/client/elm/DecodeFlags.elm
index 5acc4f9..7709e5d 100644
--- a/src/client/elm/DecodeFlags.elm
+++ b/src/client/elm/DecodeFlags.elm
@@ -1,6 +1,6 @@
module DecodeFlags exposing (Flags, init)
-import Json.Decode exposing (Decoder, andThen, fail, string, succeed)
+import Json.Decode exposing (Decoder, andThen, decodeValue, fail, list, string, succeed)
import Json.Decode.Pipeline exposing (decode, required)
import Model exposing (..)
@@ -11,7 +11,7 @@ type alias Flags =
init : Flags -> ( Model, Cmd msg )
init flags =
- case Json.Decode.decodeValue decodeUsers flags of
+ case decodeValue decodeUsers flags of
Ok user ->
( Model user, Cmd.none )
@@ -21,17 +21,14 @@ init flags =
decodeUsers : Decoder (List User)
decodeUsers =
- Json.Decode.list decodeUser
+ list
+ (decode User
+ |> required "type" decodeUserType
+ |> required "value" string
+ )
-decodeUser : Decoder User
-decodeUser =
- decode User
- |> required "type" decodeUserType
- |> required "value" string
-
-
-decodeUserType : Json.Decode.Decoder UserType
+decodeUserType : Decoder UserType
decodeUserType =
string
|> andThen