Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mixedCase/bf3aa4771c5aca800c0dd7e7f6f4158c to your computer and use it in GitHub Desktop.
Save mixedCase/bf3aa4771c5aca800c0dd7e7f6f4158c to your computer and use it in GitHub Desktop.
ExperimentElmRecordUpdate.elm
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