aboutsummaryrefslogtreecommitdiff
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
parent5348b220c8ec071eee01578f0ea525e28d3a5c3f (diff)
Refactor DecodeFlags
-rw-r--r--src/client/elm/DecodeFlags.elm19
-rw-r--r--src/client/static/elm.js16
2 files changed, 16 insertions, 19 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
diff --git a/src/client/static/elm.js b/src/client/static/elm.js
index 99bf4cb..4447609 100644
--- a/src/client/static/elm.js
+++ b/src/client/static/elm.js
@@ -7909,16 +7909,16 @@ var _user$project$DecodeFlags$decodeUserType = A2(
}
},
_elm_lang$core$Json_Decode$string);
-var _user$project$DecodeFlags$decodeUser = A3(
- _NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$required,
- 'value',
- _elm_lang$core$Json_Decode$string,
+var _user$project$DecodeFlags$decodeUsers = _elm_lang$core$Json_Decode$list(
A3(
_NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$required,
- 'type',
- _user$project$DecodeFlags$decodeUserType,
- _NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$decode(_user$project$Model$User)));
-var _user$project$DecodeFlags$decodeUsers = _elm_lang$core$Json_Decode$list(_user$project$DecodeFlags$decodeUser);
+ 'value',
+ _elm_lang$core$Json_Decode$string,
+ A3(
+ _NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$required,
+ 'type',
+ _user$project$DecodeFlags$decodeUserType,
+ _NoRedInk$elm_decode_pipeline$Json_Decode_Pipeline$decode(_user$project$Model$User))));
var _user$project$DecodeFlags$init = function (flags) {
var _p1 = A2(_elm_lang$core$Json_Decode$decodeValue, _user$project$DecodeFlags$decodeUsers, flags);
if (_p1.ctor === 'Ok') {