-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Classes and Decorators? #4
Comments
Thanks for your attention. The original purpose of this library is based on hyperapp and try to follow the Elm's API as same as possible via TypeScript. There is no class in Elm but just functions and modules, so we kept this in hydux. I known classes syntax have many advantages, like really good support in TS, don't need currying to pass state and actions. But if we adopt this syntax in hydux, there will be some problem that we have to resolve:
e.g. // someParentComponent.tsx
import Counter from './counter'
export const init = () => {
const counter1 = Counter.init()
return {
state: counter1.state,
cmd: Cmd.map(_ => _.counter1, counter1.cmd)
}
}
export const actions = {
counter1: Counter.actions,
}
export const view = (state, actions) => {
return (
<div>{Counter.view(state.counter1, actions.counter2)}</div>
)
} You can find the child component's state, actions and view are all exposed to parent component, this's what we called the Elm Architecture, and also the main differences between redux/mobx, we keep React's fractal architecture even in the single state and logic.
Thanks for your advice! |
it's very helpful to me! |
Just for curiosity, if we use TypeScript decorators, is it possible to turn this:
into
The text was updated successfully, but these errors were encountered: