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 MessageFailedCallback if the push times-out.
type Msg = MessageTimeout | ...
payload =
Json.Encode.object [("msg", "Hello Phoenix")]
init "room:lobby" "new_msg"
|> withPayload
|> onTimeout MessageTimeoutApplies the function on the onOk, onError and onTimeout callbacks
The message abstraction