An Elm client for Phoenix Channels.
This package makes it easy to connect to Phoenix Channels, but in a more declarative manner than the Phoenix Socket Javascript library. Simply provide a Socket
and a list of Channel
s you want to join and this library handles the unpleasent parts like opening a connection, joining channels, reconnecting after a network error and managing replies.
Declare a socket you want to connect to and the channels you want to join. The effect manager will open the socket connection, join the channels. See Phoenix.Socket
and Phoenix.Channel
for more configuration details.
import Phoenix
import Phoenix.Socket as Socket
import Phoenix.Channel as Channel
type Msg = NewMsg Value | ...
socket =
Socket.init "ws://localhost:4000/socket/websocket"
channel =
Channel.init "room:lobby"
-- register an handler for messages with a "new_msg" event
|> Channel.on "new_msg" NewMsg
subscriptions model =
Phoenix.connect socket [channel]
A simple example chat application can be found here.
Since this package is an effect manager it is at the moment not aviable via elm package. Thus the recommended way to install the package is to simply clone the project and to specify the relative path to the project in the elmBrunch
part of the the brunch-config.js
(example).