Felienne Hermans
Felienne Hermans
December 23rd, 2021

Code Reading Club Reading Countdown - 23

Article cover photo

Countdown - Snippet 23

Today, a snippet in Elm submitted by CRC organizer Dan Fishgold!

Snippet

CRCRC-23

Snippet in text

update : Nav.Key -> Msg -> Model -> ( Model, Cmd Msg )
update key msg model =
    case msg of
        EditRoomId roomIdString ->
            ( { model | roomIdString = roomIdString }, Cmd.none )

        JoinExistingRoom ->
            case RoomId.fromString model.roomIdString of
                Err err ->
                    ( { model | submission = Failure err }, Cmd.none )

                Ok roomId ->
                    ( { model | submission = Loading }
                    , sendFromHome (FindRoom roomId)
                    )

        CreateNewRoom ->
            ( model, Route.push key Route.Create )

Question

Write a summary of this code snippet.

Submission

Submit your answer in our form.