An Elm client for Phoenix Channels
Previously things got messy if there were connections to multiple websockets. Thanks to @edennis (#40) this is now resolved :)
This adds:
This release just adds
Channel.map: (a -> b) -> Channel a -> Channel b
and
Socket.map: (a -> b) -> Socket a -> Socket b
This updates to source code to Elm 0.18.
Based on the PR #5 from @opsb there are three new callbacks in Phoenix.Socket
:
{-| Set a callback which will be called if the socket connection got closed abnormal, i.e.,
if the server declined the socket authentication. So this callback is useful for updating
query params like access tokens.
type Msg =
RefreshAccessToken | ...
init "ws://localhost:4000/socket/websocket"
|> withParams [ ( "accessToken", "abc123" ) ]
|> onAbnormalClose RefreshAccessToken
-}
onAbnormalClose : msg -> Socket msg -> Socket msg
{-| Set a callback which will be called if the socket connection got closed normal. Useful if
you have to do some additional clean up.
-}
onNormalClose : msg -> Socket msg -> Socket msg
{-| Set a callback which will be called if the socket connection got closed.
You can learn more about the code [here](https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent).
-}
onClose : ({ code : Int, reason : String, wasClean : Bool } -> msg) -> Socket msg -> Socket msg
This also resulted in a change of the Socket
type from Socket
to Socket msg
.