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(store): preserve the event name case with createActionGroup #3832

Conversation

markostanimirovic
Copy link
Member

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?

Closes #3693

All letters of the event name will be lowercase, except for the initial letters of words starting from the second word, which will be uppercase.

What is the new behavior?

The initial letter of the first word of the event name will be lowercase, and the initial letters of the other words will be uppercase. The case of other letters in the event name will remain the same.

Does this PR introduce a breaking change?

[x] Yes
[ ] No

BREAKING CHANGES:

The event name case is preserved when converting to the action name by using the createActionGroup function.

BEFORE:

All letters of the event name will be lowercase, except for the initial letters of words starting from the second word, which will be uppercase.

const authApiActions = createActionGroup({
  source: 'Auth API',
  events: {
    'LogIn Success': emptyProps(),
    'login failure': emptyProps(),
    'Logout Success': emptyProps(),
    logoutFailure: emptyProps(),
  },
});

// generated actions:
const {
  loginSuccess,
  loginFailure,
  logoutSuccess,
  logoutfailure,
} = authApiActions;

AFTER:

The initial letter of the first word of the event name will be lowercase, and the initial letters of the other words will be uppercase. The case of other letters in the event name will remain the same.

const {
  logInSuccess,
  loginFailure,
  logoutSuccess,
  logoutFailure,
} = authApiActions;

@netlify
Copy link

netlify bot commented Apr 5, 2023

Deploy Preview for ngrx-io ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 13972c2
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/64484e165bfa06000865cd11
😎 Deploy Preview https://deploy-preview-3832--ngrx-io.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Join<TitleCase<Lowercase<Trim<EventName>>>>
Join<TitleCase<EventName>>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trim is also removed here because spaces will be removed by Join anyway.

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Do you think that we also need to update the docs?

An action group uses the event descriptions to create properties within the group that represent the action(s). The property names are auto-generated and are the camelCased version of the event description

@markostanimirovic
Copy link
Member Author

LGTM 👍

Do you think that we also need to update the docs?

An action group uses the event descriptions to create properties within the group that represent the action(s). The property names are auto-generated and are the camelCased version of the event description

This sentence is still valid because we're still camel-casing the event name. 😅

I plan to improve the "Action Group" page and also add an alternative way of defining event names in a separate PR.

@markostanimirovic markostanimirovic force-pushed the feat/store/createActionGroup-event-name-case branch from ec219aa to 3c29f9d Compare April 7, 2023 14:18
@markostanimirovic markostanimirovic force-pushed the feat/store/createActionGroup-event-name-case branch from 3c29f9d to 59cbb12 Compare April 17, 2023 19:14
Closes ngrx#3693

BREAKING CHANGES:

The event name case is preserved when converting to the action name by using the `createActionGroup` function.

BEFORE:

All letters of the event name will be lowercase, except for the initial letters of words starting from the second word, which will be uppercase.

```ts
const authApiActions = createActionGroup({
  source: 'Auth API',
  events: {
    'LogIn Success': emptyProps(),
    'login failure': emptyProps(),
    'Logout Success': emptyProps(),
    logoutFailure: emptyProps(),
  },
});

// generated actions:
const {
  loginSuccess,
  loginFailure,
  logoutSuccess,
  logoutfailure,
} = authApiActions;
```

AFTER:

The initial letter of the first word of the event name will be lowercase, and the initial letters of the other words will be uppercase. The case of other letters in the event name will remain the same.

```ts
const {
  logInSuccess,
  loginFailure,
  logoutSuccess,
  logoutFailure,
} = authApiActions;
```
@markostanimirovic markostanimirovic force-pushed the feat/store/createActionGroup-event-name-case branch from 59cbb12 to 13972c2 Compare April 25, 2023 22:03
Copy link
Member

@brandonroberts brandonroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allows createActionGroup to preserve the case
3 participants