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

WithDevTools code repetition when used with withRedux #80

Open
marcindz88 opened this issue Aug 5, 2024 · 2 comments
Open

WithDevTools code repetition when used with withRedux #80

marcindz88 opened this issue Aug 5, 2024 · 2 comments

Comments

@marcindz88
Copy link
Contributor

Hi
I would love to see a feature where we can define updateState with redux on functions more easily without repeating action name twice.
Current code to include action name in redux dev tools looks like this:

on(actions.updateSomeEntity, (state, { entity }) =>
  updateState(
    state,
    actions.updateSomeEntity.type,
    updateEntity({ id: entity.id, changes: entity }, { collection: 'entity' })
    )
);

I tried to create a wrapper that will accept on with some configuration, but failed because some internal types are not exported.

Also I have not seen anything the docs about updateState so it's worth including I think, as I found it by accident.

@marcindz88
Copy link
Contributor Author

The solution could include moving the updateState logic into the on function, resulting in code:

on(actions. updateSomeEntity, ({ entity }) => addEntity(entity, ENTITY_COLLECTION));

@rainerhahnekamp
Copy link
Collaborator

@marcindz88, I've updated the docs and added updateState. I agree that your version of the on function is something we should add but I think, it will be available in the new version of the redux where we decouple actions from the store.

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

No branches or pull requests

2 participants