Skip to content

does redux-actions support prefixing types? #195

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

Closed
tugorez opened this issue Feb 26, 2017 · 3 comments
Closed

does redux-actions support prefixing types? #195

tugorez opened this issue Feb 26, 2017 · 3 comments

Comments

@tugorez
Copy link

tugorez commented Feb 26, 2017

Hi everyone, I'm trying to figure out if something like this is currently possible with redux-actions:

const prefix = 'some_random_prefix';
const type1 = 'SOME_RANDOM_TYPE_1';
const type2 = 'SOME_RANDOM_TYPE_2';
const type3 = 'SOME_RANDOM_TYPE_3';
const {
  someRandomType1,
  someRandomType2,
  someRandomType3,
} = createActions(
  { prefix },
  type1,
  type2,
  type3,
);
expect(someRandomType1().type).toEqual(`${prefix}/${type1}`);
expect(someRandomType2().type).toEqual(`${prefix}/${type2}`);
expect(someRandomType3().type).toEqual(`${prefix}/${type3}`);

and if not, might i know why? Thank you for your time :)

For example, react-boilerplate endorses the fact of prefixing types to prevent unwanted behavior in reducers.

@yangmillstheory
Copy link
Contributor

Take a look at #159. I'll get this in tomorrow.

@tugorez
Copy link
Author

tugorez commented Feb 26, 2017

My main concern is about being able to declare more than one action-creator with the same name and not being worried about unexpected behaviour because all of them will create actions with the same type and all those actions will be catched by many reducers (unintendedly).

@yangmillstheory I did a module that wraps createAction ( I just did it for fun, It is really limited and just works in the case you use createActions with literal types).
If there is something I could help you with, please tell me.

Sorry for my bad english.

@yangmillstheory
Copy link
Contributor

No problem. See this comment: #159 (comment)

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