git-toni / lv-states Goto Github PK
View Code? Open in Web Editor NEWCommon state-management for Phoenix Liveview Sockets needed by interactive applications.
License: MIT License
Common state-management for Phoenix Liveview Sockets needed by interactive applications.
License: MIT License
Include:
TODO
Export a LVComponent that makes rendering queryable filter easier
When using any of the lvs helpers, we could make sure the fetcher does exist.
It's currently within its own state key
Features:
Seems like a useful library on itself even, it could become its own separate hex package as a generic way to LV-render the status of the socket's assigns.
Whenever there is a resource to be fetched asynchronously, it's often useful to have a small set of states to cover that need.
data
: can either be empty or contain the information to be renderedis_fetching
: can be either true
or `false.error
: is nil or contains a fetching errormetadata
: contains meta information such as number of records, pagination status, etc.API
The module allows for each field to be initialized as is_fetching: true/false
. By default all fields are initialized as not feching.
The following usage:
use WithFetcheable, [results: :fetching, :shops]
will build a "fetching" state, ie:
%{
results: %{
data: nil,
is_fetching: true,
metadata: nil,
error: nil,
},
shops: %{
data: nil,
is_fetching: false,
metadata: nil,
error: nil,
}
}
It's up to the Liveview.mount/3 callback to implement the actual fetching.
The number of names sub-states lvs_data
, lvs_filters
, lvs_search
is becoming scattered.
TODO
%Socket{ assigns: %{ lvs: %LvsState{ data, filters, search, ...}}}
TODO
Export a LVComponent that makes rendering multi-select or single-select easier
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.