Last active
May 1, 2019 02:20
-
-
Save glinesbdev/b2b9c49cab42c61a4d5312dc30cd8b42 to your computer and use it in GitHub Desktop.
Cmd.batch Example
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 Msg | |
= UrlRequested Browser.UrlRequest | |
| UrlChanged Url.Url | |
| NameEntered String | |
| NameSubmitted | |
| MessageEntered String | |
| MessageSubmitted | |
| GenerateRandomId String | |
generateRandomChatId : Cmd Msg | |
generateRandomChatId = | |
Random.generate GenerateRandomId <| RandomString.string 10 RandomChar.latin | |
NameSubmitted -> | |
( { model | |
| route = authRoute (canEnterChat model) Chat | |
, chatName = | |
clearChatName | |
(authRoute (canEnterChat model) Chat) | |
(String.trim model.chatName) | |
, errors = formErrors <| canEnterChat model | |
} | |
, Cmd.batch | |
[ generateRandomChatId | |
, authChangeUrl (canEnterChat model) model.key chatPath | |
] | |
) | |
GenerateRandomId id -> | |
( { model | chatterId = String.concat [ model.chatName, "-", id ] } | |
, Cmd.none | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment