Replies: 4 comments 1 reply
-
Perhaps getters and setters should be polymorphic, that is, support getting and setting specific properties within the store reference. Consider the example:
|
Beta Was this translation helpful? Give feedback.
-
It's easy get a reference for a nested object:
What you're describing would be like a store rescope feature.
This might be a new feature of stores. I wouldn't mix that with refs. Definitely an interesting idea. |
Beta Was this translation helpful? Give feedback.
-
Exactly. That would solve a bunch of problems due to hardcoding some store paths in multiple files. It would also be great if we could use store refs to add/remove triggers. Something like this:
|
Beta Was this translation helpful? Give feedback.
-
Hi @mstijak can you help me if the store refs are included in the current version of cx I have installed:
Thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
This is a new proposal for store refs following #482 and #347.
Store refs would reduce the number of string bindings and optionally add typing.
The second argument could be the initial value.
Typed store refs would allow easier array or tree operations.
For trees, it would be slightly more complicated as it's required to know the
childrenField
.Store refs would work nicely with functional controllers.
It might be possible to make functional components to work with store refs too. However, that would require that widgets support getting data from external stores.
This change might introduce problems as developers might be tempted to create new stores on the fly.
In this case, the top-level store would never get notified and the UI would not re-render on changes originating in the component. Does the simplicity outweights the danger?
Beta Was this translation helpful? Give feedback.
All reactions