Basic application with simple LiveView implementations:
- message board
- random quotes generator
Slides from presentation: https://www.slideshare.net/quatermain1/rubyslava-phoenix-liveview
To start your Phoenix server:
- Install dependencies with
mix deps.get
- Start Phoenix endpoint with
mix phx.server
or inside IEx withiex -S mix phx.server
Now you can visit localhost:4000
from your browser.
Ready to run in production? Please check our deployment guides or just deploy it with fly.io:
- Install cli
more: https://fly.io/docs/getting-started/installing-flyctl/
brew install superfly/tap/flyctl
- Login or sign up
flyctl auth login # or flyctl auth signup
- Create & Deploy app
fly launch
Simple list of messages stored in memory with Agent implementation. This messages list is loaded and updated by every running LiveView instances. Agent implementation is just simulation of some kind of storage for these messages. It's not recommended to use in real use cases.
Every new message is broadcasted with Phoenix PubSub to other running LiveView processes. This implementation is example how can be optimized storage management for better performance. Filtering new questions is not optimized and I can say using Enum.uniq_by/2
is wrong, but it works for this example.
List of quotes is downloaded from publicly available Gist in GenServer implementation. After the list is loaded it will take one random quote and broadcast it to channel. Broadcasting is implemented with Phoenix PubSub and it will delivery messages(quotes) to every process which is subscribed to specific channel. Simple LiveView implementation is subscribed to this channel and automatically show every quotes in UI immediately when is broadcasted.
- Official website: https://www.phoenixframework.org/
- Guides: https://hexdocs.pm/phoenix/overview.html
- Docs: https://hexdocs.pm/phoenix
- Forum: https://elixirforum.com/c/phoenix-forum
- Source: https://github.com/phoenixframework/phoenix