Phoenix Framework is a web development framework written in Elixir which uses the Erlang virtual machine - BEAM. You can build fast and performant websites which can scale to millions of connections.
Similar to Ruby on Rails - Phoenix uses convention over configuration. This means the directory structure and locations of files within are important for the web framework to find the files it needs.
Channels
Phoenix Channels are a real-time communication mechanism built on top of WebSockets.
Conceptually, they fit the Pub/Sub side of Concurrent Programming and are a practical example of message-based coordination in the Actor Model.
They are commonly used when the server needs to push updates to the browser without a full page reload.
Live views
Live Views use Phoenix Channels and a long-lived WebSocket connection in the browser to update page state on the fly.
For a live view 3 functions are important:
# Mount called to set up live view
def mount() do
{:ok, socket}
end
# Render called when data changes
def render() do
{:noreply, socket}
end
# Event handler called when event happens
def handle_event() do
{:noreply, socket}
endSee also: