You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I really like the idea of putting a proxy over the stores (vxm) and abstracting all the mutations and mapX decorators. I found your package while doing research on how to achieve this myself and decided to use it (nice work btw, very neat). However, in order to achieve 2-way binding, I realized I had to define getters and setters on the component like so:
Not bad given the usual boilerplate required to do that, but I decided to go one step further and just define the store module on the component (would be nice to include this in README):
privateexample=vxm.example;
However, this meant that every time I need to use a field, I would have to address it with the full path (e.g. example.foo). So, I came up with the following decorator:
This does the job but it's just too loose. There's no guarantee that the types are the same or that this field exists in the store at all so you will only find out you made a mistake during runtime. Any way to make it cleaner?
Ideally, it should be something like this:
@Bind(vxm.example.foo)privatefoo;
However, this requires that foo is passed by reference, which can only be achieved if there's a proxy over primitive fields and I assume this isn't exactly performance friendly (I might be wrong about this), so to dodge that maybe something like:
@Bind(vxm.example.bindable.foo)privatefoo;
Which can perhaps be achieved with an extending submodule?
What do you think? Just over-engineering or a nice feature to add? I haven't read your code yet so there might be a much easier way to do this.
The text was updated successfully, but these errors were encountered:
I really like the idea of putting a proxy over the stores (vxm) and abstracting all the mutations and mapX decorators. I found your package while doing research on how to achieve this myself and decided to use it (nice work btw, very neat). However, in order to achieve 2-way binding, I realized I had to define getters and setters on the component like so:
Not bad given the usual boilerplate required to do that, but I decided to go one step further and just define the store module on the component (would be nice to include this in README):
However, this meant that every time I need to use a field, I would have to address it with the full path (e.g.
example.foo
). So, I came up with the following decorator:In the class component:
In the template:
This does the job but it's just too loose. There's no guarantee that the types are the same or that this field exists in the store at all so you will only find out you made a mistake during runtime. Any way to make it cleaner?
Ideally, it should be something like this:
However, this requires that foo is passed by reference, which can only be achieved if there's a proxy over primitive fields and I assume this isn't exactly performance friendly (I might be wrong about this), so to dodge that maybe something like:
Which can perhaps be achieved with an extending submodule?
What do you think? Just over-engineering or a nice feature to add? I haven't read your code yet so there might be a much easier way to do this.
The text was updated successfully, but these errors were encountered: