Skip to content
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

feat(schematics): add the ability to create actions with the prefix #3025

Merged

Conversation

mateuszbasinski
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The actions are created only with the prefix Load.

Closes #3012

What is the new behavior?

The actions are created with a specified prefix.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@ngrxbot
Copy link
Collaborator

ngrxbot commented May 19, 2021

Preview docs changes for ef7553c at https://previews.ngrx.io/pr3025-ef7553cc/

@mateuszbasinski mateuszbasinski force-pushed the feat/create-actions-with-prefix branch from 733e2cb to 3b565b4 Compare May 20, 2021 07:07
@mateuszbasinski
Copy link
Contributor Author

@timdeschryver I came up with the idea to generate actions with many prefixes by using one command. For example - for the action schematics we can pass an array with prefixes ([load, create, update, delete]) and then generate actions with all prefixes from the array. What do you think about this idea?

@timdeschryver
Copy link
Member

@mateuszbasinski I think that's a good idea.
I just don't know if the Angular CLI would parse a comma separated input correctly.
Have you tried that?

The only downside is that this leads to command-driven actions, while we encourage event-driven actions.
But the currently implementation also "violates" this practice 😅

@mateuszbasinski
Copy link
Contributor Author

@timdeschryver I tried to deal with this using split. The output of splitted array looks good.
image

@timdeschryver
Copy link
Member

Then I think we can extend the schematic to create multiple defaults, as long as the default remains "load".

@brandonroberts
Copy link
Member

I think this PR is good, but I don't think we should add comma-separated prefixes. As Tim mentioned, we're already violating event-driven actions, so I want to change those to be more correct, such as:

[Users Page] (Init/Load Users/Some other Event)
[Users Page/API] Users Loaded Success
[Users Page/API] Users Loaded Failure

I also think the goal of the schematics is to generate the minimum of what you need, and not try to auto-generate everything.

@brandonroberts brandonroberts merged commit 15bc0df into ngrx:master May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to specify action name with custom prefix in actions schematics.
4 participants