Skip to content

Instantly share code, notes, and snippets.

@arsduo
Created October 15, 2018 13:22
Show Gist options
  • Save arsduo/3545c79fa47fc6130eb372ebc71eaf3b to your computer and use it in GitHub Desktop.
Save arsduo/3545c79fa47fc6130eb372ebc71eaf3b to your computer and use it in GitHub Desktop.
type Msg
= PlayVideo VideoId
| VideoPlayAdvanced { currentSecond : Int, totalLength : Int }
| ReadTextAloud
| Login AuthToken UserInformation
logMessage : Msg -> Maybe { message : String, data : Json.Encode.Value }
logMessage msg =
case msg of
PlayVideo (VideoId id) ->
Just { message = "PlayVideo", data = Json.Encode.int id }
VideoPlayAdvanced ->
Nothing
Login AuthToken UserInformation ->
Just { message = "Login", data = Json.Encode.null }
ReadTextAloud ->
Just { message = "ReadTextAloud", data = Json.Encode.null }
-- if you're not optimized, you _could_ replace the previous line entry and any others with this...but see below
_ ->
Just { message = Debug.toString msg, data = Json.Encode.null }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment