Skip to content

zapnito/elm-phoenix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-phoenix

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 Channels 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.

Getting Started

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]

Example

A simple example chat application can be found here.

Installation:

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).

About

An Elm client for Phoenix Channels

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elm 66.0%
  • Elixir 27.4%
  • JavaScript 5.4%
  • HTML 1.2%