4 ms·
> I'd like to see that presentation. Got a link to the slides? If you're willing to wait a week, I could share. I'm really not ready to share it as is (still w
by Octoth0rpe 7y ago
> I'd like to see that presentation. Got a link to the slides?
If you're willing to wait a week, I could share. I'm really not ready to share it as is (still working on the code).
> Could you leave a comment at https://github.com/reduxjs/redux/issues/3313 https://github.com/reduxjs/redux/issues/3313 with some notes on how the current docs examples are too verbose?
Yes, I could do that, but again I'll need at least a couple of days. It's a crazy week for me.
If you want a _quick_ example, here's one from the 'actions' section of the basic tutorial:
------
function addTodo(text) {
return {
type: ADD_TODO,
text
}
}
------
I would advocate writing this as:
const addTodo = (payload) => ({
type: ADD_TODO,
payload,
});
-------
4 lines instead of 6, just as readable to me. And frankly, I'd consider doing that as a 1-liner since there's only two attributes in the action anyway. Where I work, we have a semi-official rule of 'newlines for attributes if there are more than 3, or if the line length > 80', so our policy would write this action creator as a single line.
export const addTodo = payload => ({ type: ADD_TODO, payload });
- acemarke 7y agoSure, no worries. Ping me on Twitter (@acemarke) when you've got it posted, or just leave a comment in that issue and I'll see it. For that example, it's a combination of: - ES6 was barely finalized when the docs first came out - Questions of clarity and familiarity with arrow functions. Fortunately, with Redux Starter Kit, you don't even have to write action creators or action types by hand any more :)
- efdee 7y agoconst addTodo = action(ADD_TODO);