https://github.com/git-toni/lv-states
Common state-management for Phoenix Liveview Sockets needed by interactive applications.
https://github.com/git-toni/lv-states
elixir interactive liveview websockets
Last synced: about 1 year ago
JSON representation
Common state-management for Phoenix Liveview Sockets needed by interactive applications.
- Host: GitHub
- URL: https://github.com/git-toni/lv-states
- Owner: git-toni
- License: mit
- Created: 2021-06-26T21:33:31.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-10-04T13:40:28.000Z (over 4 years ago)
- Last Synced: 2025-03-01T05:04:28.442Z (over 1 year ago)
- Topics: elixir, interactive, liveview, websockets
- Language: Elixir
- Homepage:
- Size: 474 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README

[]()
# Lv-States
**lv-states** (short for LiveView States) provides a handful of state management helpers for [Phoenix LiveView Sockets](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.Socket.html) with the aim of simplifying common needs of client <> server communication present in interactive applications.
See it in action at [https://lv-states.fly.dev](https://lv-states.fly.dev)
### Documentation
Read the full documentation at https://hexdocs.pm/lv_states/
### Installation
```elixir
def deps do
[
{:lv_states, "~> 0.1.1"}
]
end
```
## WithSearch
Useful for those situations in which a search is present in the UI.
### Usage
```elixir
defmodule CarInventory do
use LvStates.WithSearch, [:model]
#...rest of functions
end
```
You can now comfortably point your client events to the new event handler, Eg.
```leex
```
For a full example please see the source of the [demo](/demo)
## WithFilter
Useful for multi-value fields.
### Usage
```elixir
defmodule CarInventory do
use LvStates.WithFilter, [brand: :multiple]
#...rest of functions
end
```
Send events from a collection of options to the event handler like this:
```leex
<%= for b <- @brands do %>
<%= b %>
<% end %> %>
```
For a full example please see the source of the [demo](/demo)
## TODO
- Migrate phoenix demo app to esbuild
- Use Utils.socket_set_field for WithSearch helper
- Create test utils functions to obtain useful structs
- Check that values added are binary not nil
- Compilation-time check that "fetch" or dynamic fetcher function exists in the host module