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

Allows createActionGroup to preserve the case #3693

Closed
1 of 2 tasks
hadrien-toma opened this issue Dec 4, 2022 · 7 comments · Fixed by #3832
Closed
1 of 2 tasks

Allows createActionGroup to preserve the case #3693

hadrien-toma opened this issue Dec 4, 2022 · 7 comments · Fixed by #3832

Comments

@hadrien-toma
Copy link
Contributor

Which @ngrx/* package(s) are relevant/related to the feature request?

store

Information

I would like to be able to preserve the case of the event keys I put 😬

image

By the way: thank you very much for the improved APIs, I am totally fan!

Describe any alternatives/workarounds you're currently using

image

Unfortunately it will considerably increase any refactoring effort, I really like to have the name of my action being the name of its variable + (removing the spaces for the name of actions allows to have more characters visible in the Redux DevTools which helps a lot in case of long names).

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@hadrien-toma
Copy link
Contributor Author

I also just noticed the µ character in the string 'µ My Super Specific Foo is not the same as the one get with mySuperSpecificActions.µMySuperSpecificFoo but the one in the string is... the one I typed on my keyboard 😬

@hadrien-toma
Copy link
Contributor Author

Just to have the info here : the PR associated to this issue was closed because it is introducing a breaking change (see the comments in the PR).

For now I then had to postpone the use of action groups.

@TJMaria
Copy link

TJMaria commented Jan 3, 2023

I'm also postponing the use of action groups for this reason.
One of big downsides is that it makes it harder to find where certain actions are used in the code.

I think this is essential... ex. For a developer that is new to a project/codebase

@TJMaria
Copy link

TJMaria commented Jan 3, 2023

For now i'm using a static class with utility functions as an alternative to createActionGroup
see #3736 (comment)

@martinkasa
Copy link

Find all references is not able to find action reference in createActionGroup in VS Code and vice versa. It is quite a big issue for navigating in a code. Maybe this PR solves that?

@TJMaria
Copy link

TJMaria commented Jan 6, 2023

@martinkasa My workaround resolves that problem, with minimal extra code.
Hopefully the issue can be fixed in NgRx lib itself

@markostanimirovic
Copy link
Member

The less-destructive conversion from event name to action name will be introduced in v16. It will work in the following way:

Event Name Action Name
usersLoadedSuccess usersLoadedSuccess
Users Loaded Success usersLoadedSuccess
users loaded success usersLoadedSuccess
Users loaDed SuccEss usersLoaDedSuccEss

markostanimirovic added a commit to markostanimirovic/platform that referenced this issue Apr 5, 2023
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 added a commit to markostanimirovic/platform that referenced this issue Apr 7, 2023
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 added a commit to markostanimirovic/platform that referenced this issue Apr 17, 2023
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 added a commit to markostanimirovic/platform that referenced this issue Apr 25, 2023
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;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment