Last active
March 8, 2017 03:46
-
-
Save john-kelly/56797a8b26775cfc3cb48198ee273b1f to your computer and use it in GitHub Desktop.
ExperimentElmRecordUpdate.elm
This file contains hidden or 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
[{name="john", age=100}, {name="jessta", age=100}, {name="mixed", age=100}] | |
|> List.map (\u -> {u | name = toUpper u.name}) | |
[{name="john", age=100}, {name="jessta", age=100}, {name="mixed", age=100}] | |
|> List.map {u | name = toUpper u.name} | |
[{name="john", age=100}, {name="jessta", age=100}, {name="mixed", age=100}] | |
|> List.map (\u -> !name (toUpper u.name) u) | |
[{name="john", age=100}, {name="jessta", age=100}, {name="mixed", age=100}] | |
|> List.map (!name toUpper) |
This file contains hidden or 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 model.posts) | |
UpdateNewPostData data -> | |
model | |
|> !posts (!newPost data model.posts) | |
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 model.user) | |
|> !user (!showNewNameModal False model.user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment