markerikson / marks-dev-blog-comments

Comments for my blog
4 stars 0 forks source link

Practical Redux, Part 8: Form Draft Data Management #12

Open markerikson opened 4 years ago

markerikson commented 4 years ago

Original author: Daniel @danielmartinprieto
Original date: 2017-02-05T20:14:22Z

Hey, awesome post, as usual! I have a question regarding thunks, as I've seen you commenting about this on Twitter before: shouldn't these thunks be just normal action creators dispatching only one action type, letting the different reducers handle the logic? I understand you can place this logic in both places (action creators or reducers), but in this case, if something happens in the middle of two dispatches in a thunk, we'd have an inconsistent state, right?

markerikson commented 4 years ago

Original date: 2017-02-05T21:21:28Z

Thanks! And good questions, as usual :)

The question of where to put logic comes up fairly frequently, which is why I wrote an FAQ entry on the topic: http://redux.js.org/docs/fa... .

It would be a valid approach to dispatch, say, a `PILOT_EDIT_CANCEL` action, and have the reducers respond by doing the multiple various things needed in response. I've opted to go the route of having more "primitive" actions that can be reused and composed in various use cases.

Per your question on "inconsistent states", my "Idiomatic Redux: Thoughts on Thunks" post actually addresses that question specifically. See this section: http://blog.isquaredsoftwar... .

markerikson commented 4 years ago

Original author: Richard Hoffmann @richardhoffmann
Original date: 2017-02-09T16:48:13Z

Thank you again for this post!

markerikson commented 4 years ago

Original author: Ioosth @ioosth
Original date: 2017-03-11T08:42:01Z

Mark, could you let us know when should we expect the next part?

markerikson commented 4 years ago

Original date: 2017-03-11T22:51:57Z

I'm absolutely planning to continue the series, but it may be a couple months before I have time to write the next "Practical Redux" post. I've got some travel coming up, a couple side tasks I need to tackle, and also Mass Effect: Andromeda comes out in a week :) I have a very good idea what I want to cover next, just gotta have the time to work on it.

Thanks for the interest!