Forked from john-kelly/Experiment2ElmRecordUpdate.elm
Last active
March 8, 2017 03:09
-
-
Save mixedCase/bf3aa4771c5aca800c0dd7e7f6f4158c to your computer and use it in GitHub Desktop.
ExperimentElmRecordUpdate.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type alias Model = | |
{ user : User | |
, posts : Posts | |
} | |
type alias User = | |
{ userName : String | |
, userId : Int | |
, email : String | |
, displayName : String | |
, newName : String | |
, showNewNameModal : Bool | |
, following : List Int | |
} | |
type alias Posts = | |
{ | |
, elements: List Post | |
, postsPerPage : Int | |
, blocked : List Int | |
, showNewPostModal : Bool | |
, newPost : String | |
} | |
update : Msg -> Model -> Model | |
update msg model = | |
case msg of | |
ShowNewPostModal -> | |
{ model | posts.showNewPostModal = True} | |
UpdateNewPostData data -> | |
{ model | posts.newPost = data } | |
SubmitNewPost newPost -> | |
model | |
|> !posts (!elements ((Post newPost) :: model.posts.elements) model.posts) | |
|> !posts (!showNewPostModal False model.posts) | |
ShowNewNameModal -> | |
model | |
|> !user (!showNewNameModal True model.user) | |
UpdateNewNameData data -> | |
model | |
|> !user (!userName data model.user) | |
SubmitNameChange newName -> | |
model | |
|> !user (!displayName newName newName) | |
|> !user (!showNewNameModal False model.user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment