hendore/elm-port-message/2.0.0

NOTE: this package is not compatible with Elm 0.19.1

PortMessage

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

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

Builder

new : String -> PortMessage

Create a new PortMessage with an empty payload.

new "SomeAction" == { tag = "SomeAction", payload = null }
withPayload : Value -> PortMessage -> PortMessage

Attach a payload to the PortMessage

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