Skip to content

Conversation

@nikita-graf
Copy link
Contributor

This PR allows to use actions as type parameter for handleAction and handleActions like so:

let increment = createAction('INCREMENT', amount => amount);

const reducer = handleActions({
  [increment]: (state, action) => ({
    counter: state.counter + action.payload
  })
}, { counter: 0 });

handleAction(increment , {
  next(state, action) {...}
  throw(state, action) {...}
});

It prevents from copy&paste action names across modules, allows to use autocomplete in IDE.

Copy link

Choose a reason for hiding this comment

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

IMHO, it should be const instead of let.

Copy link
Member

Choose a reason for hiding this comment

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

Yup, please use const here.

@timche
Copy link
Member

timche commented May 15, 2016

Currently duplicated with #32, but when the author does not answer there, we can go with this PR. Are you fine with that?

@nikita-graf
Copy link
Contributor Author

Yes, I'm ok with that. I just want to have this feature merged through this PR or #32, it doesn't matter.

@timche
Copy link
Member

timche commented May 21, 2016

Looks like the author of #32 doesn't care anymore of his PR, so we'll go with this one.

@timche
Copy link
Member

timche commented May 21, 2016

Can you also provide some tests please?

@timche timche removed the duplicate label May 21, 2016
@nikita-graf
Copy link
Contributor Author

@timche I've added 2 tests and replaced let with const. Please review it.

@timche
Copy link
Member

timche commented May 21, 2016

@nikita-graf Thanks, but This branch has conflicts that must be resolved ;)

@nikita-graf
Copy link
Contributor Author

Didn't see that, for now it's up to date:smile:

@timche timche merged commit d1aa7d6 into redux-utilities:master May 22, 2016
@timche
Copy link
Member

timche commented May 22, 2016

Thanks @nikita-graf, merged :)

@nikita-graf
Copy link
Contributor Author

Great, thanks :)

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.

3 participants