Replies: 1 comment 5 replies
-
There are a few automatisms, i.e. multiple selections with automatically batched changes, that are impossible with this pattern. I'm sure there are ways around this, but I'm afraid they will be less convenient. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The current implementation of setStore is very convenient from a js DX point of view. Typescript however doesn't fare too well with the path based syntax which makes setStore so convenient. This impacts both maintainability of the store types as well as developer feedback, which can sometimes become a bit cryptic due to the type complexity.
Therefore I want to propose a new syntax for store setters which maintains the DX, while type complexity is greatly reduced.
Proposed syntax
The general idea is to move the path selectors from inside the store setter function to the outside. This makes it much easier to handle in typescript, as it only has to check one level of recursion at a time. A few examples:
The current approach to array modes is not compatible with this approach. I would propose the following for array typed store properties:
Discussion
I would like to see if others feel like this would improve store setters in a meaningful way. Of course there is a long way to go, but first experiments show me this syntax is possible to implement. I would like to first gather the general opinion before going ahead with an actual implementation of these ideas. For me there are the following considerations:
Pros:
Cons:
Some other points of discussion:
Beta Was this translation helpful? Give feedback.
All reactions