hendore / elm-port-message / PortMessage

Useful functions for building a PortMessage to be delivered through ports.


type alias PortMessage =
{ tag : String
, payload : Json.Encode.Value 
}

Builder

new : String -> PortMessage

Create a new PortMessage with an empty payload.

new "SomeAction" == { tag = "SomeAction", payload = null }

withPayload : Json.Encode.Value -> PortMessage -> PortMessage

Attach a payload to the PortMessage

new "JoinChannel"
    |> withPayload (Json.Encode.string "lobby")
    == { tag = "JoinChannel", payload = "lobby" }