A message to push informations to a channel.
Initialize a message with a topic and an event.
init "room:lobby" "new_msg"Attach a payload to a message
payload =
Json.Encode.object [("msg", "Hello Phoenix")]
init "room:lobby" "new_msg"
|> withPayloadCallback if the server replies with an "ok" status.
type Msg = MessageArrived | ...
payload =
Json.Encode.object [("msg", "Hello Phoenix")]
init "room:lobby" "new_msg"
|> withPayload
|> onOk (\_ -> MessageArrived)Callback if the server replies with an "error" status.
type Msg = MessageFailed Value | ...
payload =
Json.Encode.object [("msg", "Hello Phoenix")]
init "room:lobby" "new_msg"
|> withPayload
|> onError MessageFailedApplies the function on the onOk and onError callback
The message abstraction