-
Notifications
You must be signed in to change notification settings - Fork 31
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
simplify the set/get of store, just like mobx #7
Comments
This is an interesting idea. I went ahead and implemented it as an experiment in this PR. Three downsides of this sort of setter syntax:
All of these points may be reasonable compromises for the sake of simplicity. So the API would look like: withStore('a')(store =>
<div>a is {store.a}</div>
<button onClick={() => store.a++}>Add 1 to a</button>
) |
Do you consider this? Maybe better understand
|
@hackerxian I did, and thanks for bringing it up! Both syntaxes are great (in fact we could easily support all 3), but there are a few small downsides, I think:
Admittedly, these are pretty minor downsides. I think the guiding principle is: 1 way to do things, not more. |
can we automatically generate getter/setter, but not sure if we still can get advantage of compile errors. |
@zhy0216 There's no way to do that safely, unless we introduce a codegen script. |
store.get('addTodoTitle') => store.addTodoTitle
store.set('addTodoTitle') => store.addTodoTitle = ''
The text was updated successfully, but these errors were encountered: