A message to push informations to a channel.
PhoenixPush msg
The message abstraction
init : Topic -> Event -> Push msg
Initialize a message with a topic and an event.
init "room:lobby" "new_msg"
withPayload : Json.Encode.Value -> Push msg -> Push msg
Attach a payload to a message
payload =
Json.Encode.object [("msg", "Hello Phoenix")]
init "room:lobby" "new_msg"
|> withPayload
onOk : (Json.Encode.Value -> msg) -> Push msg -> Push msg
Callback 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)
onError : (Json.Encode.Value -> msg) -> Push msg -> Push msg
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 MessageFailed
onTimeout : msg -> Push msg -> Push msg
Callback if the push times-out.
type Msg = MessageTimeout | ...
payload =
Json.Encode.object [("msg", "Hello Phoenix")]
init "room:lobby" "new_msg"
|> withPayload
|> onTimeout MessageTimeout
map : (a -> b) -> Push a -> Push b
Applies the function on the onOk, onError and onTimeout callbacks