Server-driven interactive websites using the ELM architecture.
| examples | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE.txt | ||
| README.md | ||
Overview
LiveView is the term used by Elixir's Phoenix Framework to describe their approach to server-side rendering. This library implements LiveView using a ELM-like architecture. While the ELM-architecture is typically implemented entirely on the client, LiveView moves the client-server boundary between the browser and the state.
- After the initial page load, the client and server keep communicating using a WebSocket connection.
- The client sends events (e.g. button clicks) to the server.
- The state is mutated using the
Component::updatefunction. - The state is rendered to a DOM using the
Component::viewfunction. - The previous DOM and the new DOM are compared and a incremental update is generated.
- The incremental update is transmitted to the client and applied to the real DOM.
Benefits
- no state duplication between client and server
- effortless synchronisation between multiple clients
- effortless session resumption
- low bandwidth incremental updates
- no need for separate client application
- no need for api endpoints on the server
Drawbacks
- the website can only be used if the WebSocket is connected
- round trip latency for every interaction
Usage
Please take a look at the documentation and the examples. Until the public API has settled, the README would probably always be outdated.
Examples
Meta
Contributing
Contributions of any kind are always welcome. You can use the modern Issue / PR workflow or the traditional E-Mail based Git workflow.
Contact
You can contact me (the author) using issues or per E-Mail at liveview-rs@pfzetto.de.
License
This project is licensed under MPLv2;