-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Action scaffolder #80
Comments
This sounds awesome. You're right about the time consuming nature of new stubs for actions. I really like this feature. |
I ended up with some action generator like this for my own project. |
@khuongduybui oh wow I'm glad somebody else thought about this already as well. What I'd be looking in the final end is the following:
|
My situation is a little different, so I didn't elaborate. {
"user": Object,
"users": [Object],
"projects": [Object],
[...]
} I have a factory to "connect" a Feathers model with the part of the store. The factory creates simple The factory also creates listeners for Feathers model CRUD events and invokes the actions as appropriate. My code, besides the listeners, never touches my actions directly (except for my login / logout code that use the actions for |
OK I see, cool idea actually to automate that part |
I like this idea. Scaffolding helps with boiler plate code exhaustion and is great for speedy development, especially with crud-like apps where you find yourself doing the same thing over and over, just in a different app. I work with a lot of forms and I have used https://github.com/erikras/redux-form with aurelia (hacking out the react parts), but more recently I used https://github.com/final-form/final-form with aurelia to handle all my crud behavior since it is framework agnostic. The Redux-Form library might give you some more boilerplate action ideas. This may be a little off topic, but I would be interested in an extension/plugin to the store that handles CRUD changes, maybe as a long term option in addition to scaffolding. I am in the early stages of my first application with this library and am trying to solve this issue by separating this type of logic (push, slice, change etc.) into its own feature (custom element/custom attribute) in hopes that the feature could be used as a plugin, although right now it is dependent on final-form because it handles a lot of boiler plate events 😃 Update: FYI, a little easier to navigate docs to see their actions if you are interested: https://redux-form.com/7.4.2/docs/api/actioncreators.md/ |
@jmzagorski I would love to know more about your form implementation. The two way binding and reference problem in Javascript has meant I've seen numerous solutions for working with forms and sometimes issues have arisen because someone directly bound to a reference to a property from the subscriber and mutated the data. I know the documentation makes mention of this and to shallow clone, but I would love to see an official Aurelia plugin or way of working with forms. Understandably, this is an issue that plagues all state management solutions and working with form binding (especially given Aurelia is two way binding by default for form value binding). |
@Vheissu In my last application I had to deal with a ton of forms and the redux-form library approach worked pretty well. I created one custom element that had a form element and listened for all the children element change events. <template class="redux-form">
<form change.delegate="changeHandler($event)" ref="$form">
<slot></slot>
</form>
</template> This custom element emitted a redux change action in response to the change event and that action had the form name, field name from the element emitting the event and the new value. I had to do extra work to convert the string value type if the change event was from the DOM and not my custom event by inspecting the element ( e.g. My strategy this time around is a bit different since I am introducing a custom attribute and using
Still thinking this through. |
I was lately working a lot with Gherkin/Cucumber and was diving into scaffolding associated unit tests. Thats what brought me to the idea of scaffolding actions. But this is just one way to tackle forms. Having a dedicated approach via a subplugin or even part of the store would definitely make sense as it would go beyond the scope of creating actions. |
One of the things that eats up a lot of time is the creation of action stubs for new entites.
Imagine your state is like this:
now in order to have the most common CRUD - R operations you'd need three actions.
What if instead, aurelia store would also act as a cli at the same time, helping you creating those action stubs on the fly.
You can try out a basic sample by installing:
I'd be interested to hear what you think about it and what a nice collection of actions boilerplates could be.
EDIT:
Make sure to visit this discourse topic for further discussions
The text was updated successfully, but these errors were encountered: