robinweser / alveron Goto Github PK
View Code? Open in Web Editor NEWTiny (0.8kb) Elm-inspired state management for React
Home Page: https://alveron.js.org
License: MIT License
Tiny (0.8kb) Elm-inspired state management for React
Home Page: https://alveron.js.org
License: MIT License
Instead of passing everything as separate parameters, we should rather use an object to allow future additions not to extend the params even more.
// old
<Consumer>{(state, actions, effects, more, evenMore) => ...}</Consumer>
// old
<Consumer>{({ state, actions, effects, more, evenMore }) => ...}</Consumer>
It also helps to only pick the keys that are actually required without leaving blank params.
Hook that bridges Alveron stores to use useOptimistic
under the hood.
I saw there's flow in this lib but I was wondering if you plan to support typescript in the future or if you are open to receive PR about it. There's also a chance to publish a separate package on typescript types repository.
Hello, it seems a js.org
subdomain that was requested to target this repository (or another on this user/organisation) no longer works.
The subdomain requested was react-woodworm.js.org
and had the target of rofrischmann.github.io/react-woodworm
.
To keep the js.org
subdomain you should add a page with reasonable content within a month so the subdomain doesn't resolve to a 404 any longer.
Otherwise the requested subdomain will be removed from JS.ORGs zonefile and the list of active subdomains.
If you are wanting to keep the js.org
subdomain and have added reasonable content, YOU MUST reply to the main cleanup issue with the response format detailed at the top to keep the requested subdomain.
It might be helpful to implement basic shallow equality checks for the Consumer component or at least add the ability to add a custom shouldUpdate method.
We should extend the docs to explain the principles even better and to separate the API docs.
Maybe we should also use Gitbook like I usually do (fela.js.org, react-controlled-form.js.org, inline-style-prefixer.js.org).
Could look something like:
const model = []
const actions = {
setList: (_, items) => items
}
const effects = {
fetch: (actions) => fetch(....).then(actions.setList)
}
const Store = createStore({ model, actions, effects })
const SomeList = () => {
const { state, effects } = useAlveron(Store)
return (
<div>
{state.map(el => <div>{el}</div>)}
<button onClick={effects.fetch} />
</div>
)
}
Instead of exposing setState freely, we could even restrict effects more to just calling actions.
Could be great in terms of testing and separation:
const model = []
const actions = {
addUser: (state, user) => [
...state,
user
]
}
const effects = {
postUser: (actions, user) => fetch("api.com/users", {
method: 'POST',
body: JSON.stringify(user)
}).then(res => res.json()).then(actions.addUser)
}
I was wondering if there's any reason for the absence of a connect helper.
Let's say i have stateful component and I want to call an effect that fetches an API on componentDidMount
. How can i achieve it without hooks?
because right now i was trying to use Hooks but i get useAlveron
is not a function because on import it's an object and not a function, so i suppose my react version doesn't support hooks.
"react": "16.6.3",
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.