{"id":26958556,"url":"https://github.com/git-toni/lv-states","last_synced_at":"2025-04-03T04:20:01.294Z","repository":{"id":46599069,"uuid":"380599608","full_name":"git-toni/lv-states","owner":"git-toni","description":"Common state-management for Phoenix Liveview Sockets needed by interactive applications.","archived":false,"fork":false,"pushed_at":"2021-10-04T13:40:28.000Z","size":485,"stargazers_count":3,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T05:04:28.442Z","etag":null,"topics":["elixir","interactive","liveview","websockets"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/git-toni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-26T21:33:31.000Z","updated_at":"2022-10-14T16:01:01.000Z","dependencies_parsed_at":"2022-09-26T18:00:43.413Z","dependency_job_id":null,"html_url":"https://github.com/git-toni/lv-states","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/git-toni%2Flv-states","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/git-toni%2Flv-states/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/git-toni%2Flv-states/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/git-toni%2Flv-states/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/git-toni","download_url":"https://codeload.github.com/git-toni/lv-states/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246847137,"owners_count":20843444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","interactive","liveview","websockets"],"created_at":"2025-04-03T04:20:00.501Z","updated_at":"2025-04-03T04:20:01.162Z","avatar_url":"https://github.com/git-toni.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI/CD](https://github.com/git-toni/lv-states/actions/workflows/main.yml/badge.svg)\n[![Hex.pm](https://img.shields.io/hexpm/v/lv_states.svg?color=blue)]()\n# Lv-States\n\n**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 \u003c\u003e server communication present in interactive applications.\n\nSee it in action at [https://lv-states.fly.dev](https://lv-states.fly.dev)\n\n### Documentation\nRead the full documentation at https://hexdocs.pm/lv_states/\n\n### Installation\n\n```elixir\ndef deps do\n  [\n    {:lv_states, \"~\u003e 0.1.1\"}\n  ]\nend\n```\n\n## WithSearch\n\nUseful for those situations in which a search is present in the UI. \n\n### Usage\n\n```elixir\ndefmodule CarInventory do\n  use LvStates.WithSearch, [:model]\n  #...rest of functions\nend\n```\n\nYou can now comfortably point your client events to the new event handler, Eg.\n```leex\n  \u003cform phx-change=\"search-model\"\u003e\n    \u003cinput\n      type=\"text\"\n      name=\"query\"\n      phx-debounce=\"300\"\n      value=\"\u003c%= @search.model.query %\u003e\"\n      placeholder=\"Insert the model name to search\"\u003e\n  \u003c/form\u003e\n```\n\nFor a full example please see the source of the [demo](/demo)\n\n## WithFilter\n\nUseful for multi-value fields.\n\n### Usage\n\n```elixir\ndefmodule CarInventory do\n  use LvStates.WithFilter, [brand: :multiple]\n  #...rest of functions\nend\n```\nSend events from a collection of options to the event handler like this:\n\n```leex\n\u003c%= for b \u003c- @brands do %\u003e\n  \u003cdiv\n    phx-click=\"lvs-filter-set\"\n    phx-value-field=\"brand\"\n    phx-value-value=\"\u003c%= b %\u003e\"\n    \u003e\n    \u003c%= b %\u003e\n  \u003c/div\u003e\n\u003c% end %\u003e %\u003e\n```\n\nFor a full example please see the source of the [demo](/demo)\n\n## TODO\n- Migrate phoenix demo app to esbuild\n- Use Utils.socket_set_field for WithSearch helper\n- Create test utils functions to obtain useful structs\n- Check that values added are binary not nil\n- Compilation-time check that \"fetch\" or dynamic fetcher function exists in the host module","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgit-toni%2Flv-states","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgit-toni%2Flv-states","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgit-toni%2Flv-states/lists"}